-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimport-txt-stmt.html
More file actions
94 lines (92 loc) · 4.53 KB
/
import-txt-stmt.html
File metadata and controls
94 lines (92 loc) · 4.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>IMPORT TXT Statement - SQL Notebook</title>
<link rel="stylesheet" href="sqlnotebook.css">
</head>
<body>
<header>
<table class="nav">
<tr>
<td>
<a href="index.html"><img src="art/SqlNotebookIcon.png" alt="SQL Notebook (logo)" style="width: 58px; height: 58px; float: left; margin-right: 20px;"></a>
</td>
<td>
<a href="index.html" id="title">SQL Notebook</a><br>
<nav>
<ul class="nav">
<li><a href="https://github.com/brianluft/sqlnotebook/releases">Download</a></li>
<li><a href="doc.html"><span id="header-doc-long">Documentation</span><span id="header-doc-short">Docs</span></a></li>
<li><a href="https://github.com/brianluft/sqlnotebook">GitHub</a></li>
</ul>
</nav>
</td>
</tr>
</table>
<hr style="margin-top: 15px; margin-bottom: 15px;">
</header>
<article><div id="article">
<h1><code>IMPORT</code> <code>TXT</code> Statement</h1>
<p>Reads a text file (.TXT) from disk into a notebook table. Each line of text in the file becomes a two-column row
in the target table. One column contains a line number (starting at 0) and the other column contains the text of the
line.</p>
<h2>Syntax</h2><img moz-do-not-send="true" src="art/import-txt-stmt-syntax.svg" alt="" width="642" height="368"><br>
<h2>Parameters</h2>
<ul class="args">
<li><i>filename</i>: text<br>
The absolute path to the text file to read.</li>
<li><i>table-name</i>: text or identifier<br>
The name of the notebook table to read the text file into. If the table does not exist, it will be created. If it
does exist, by default new rows will be appended, but the <code>TRUNCATE_EXISTING_TABLE</code> option can be used
to overwrite the existing table data.</li>
<li><i>line-number-column-name</i>: text or identifier<br>
The name of the table column that will contain the line number (an integer starting at 1). If column names are not
specified, the default name "number" is used.</li>
<li><i>text-column-name</i>: text or identifier<br>
The name of the table column that will contain the line text. If column names are not specified, the default name
"line" is used.</li>
</ul>
<h2>Options</h2>
<ul class="opts">
<li><tt>SKIP_LINES</tt> (non-negative integer, default: 0)<br>
Indicates how many initial lines should be skipped in the input file.</li>
<li><tt>TAKE_LINES</tt> (-1 or non-negative integer, default: -1)<br>
Indicates the maximum number of text lines to read from the file, not including the lines skipped due to the
<code>SKIP_LINES</code> option. If -1 is specified, then the whole file is read.</li>
<li>
<tt>TRUNCATE_EXISTING_TABLE</tt> (0 or 1, default: 0)<br>
If the target table name exists, this option indicates whether the existing data rows should be deleted.
<ul class="enum">
<li>0 = Keep existing rows and append new rows</li>
<li>1 = Delete existing rows</li>
</ul>
</li>
<li>
<tt>TEMPORARY_TABLE</tt> (0 or 1, default: 0)<br>
If the target table name does not exist, and therefore a new table will be created, this option indicates whether
the new table will be a temporary table.
<ul class="enum">
<li>0 = Use <code>CREATE TABLE</code></li>
<li>1 = Use <code>CREATE TEMPORARY TABLE</code></li>
</ul>
</li>
<li>
<tt>FILE_ENCODING</tt> (integer 0-65535, default: 0)<br>
Indicates the text encoding to use when reading the text file. Specify 0 to detect the encoding automatically.
Any nonzero integer is treated as a Windows code page number. See <a moz-do-not-send="true" href=
"character-encodings-in-csv-and-text-files.html">Character Encodings in CSV and Text Files</a> for a list of
these code page numbers.
</li>
</ul>
<h2>Example</h2>
<pre>IMPORT TXT 'C:\file.txt' INTO table1;<br><br><i>-- Read the first line only.</i><br>IMPORT TXT 'C:\file.txt' INTO table2<br>OPTIONS (TAKE_LINES: 1);<br><br><i>-- Read the fourth and fifth lines.</i><br>IMPORT TXT 'C:\utf8.txt' INTO table3<br>OPTIONS (SKIP_LINES: 3, TAKE_LINES: 2);<br><br><i>-- Read a file in Shift-JIS encoding.</i><br>IMPORT TXT 'C:\shiftjis.txt' INTO table4<br>OPTIONS (FILE_ENCODING: 932);<br></pre>
<ol class="examples"></ol>
</div></article>
<footer><div id="footer">
<hr>
© 2016-2025 <a href="https://github.com/electroly">Brian Luft</a>
</div></footer>
</body>
</html>