You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1,"Expected 3 columns, found 4 columns",1,27,,I'm too long!
@@ -163,7 +166,7 @@ Test a file with data rows that are shorter and longer than the header row:
163
166
164
167
If any data rows are longer than the header row, you need to add columns manually: for example, by adding one or more delimiters (``,``) to the end of the header row. :code:`csvclean` can't do this, because it is designed to work with standard input, and correcting an error at the start of the CSV data based on an observation later in the CSV data would require holding all the CSV data in memory – which is not an option for large files.
165
168
166
-
Test a file with empty columns:
169
+
Process a file with empty columns:
167
170
168
171
.. code-block:: console
169
172
@@ -172,20 +175,62 @@ Test a file with empty columns:
172
175
a,,,,
173
176
,,c,,
174
177
,,,,
178
+
179
+
.. code-block:: console
180
+
:emphasize-lines: 3
181
+
175
182
$ cat errors.csv
176
183
line_number,msg,a,b,c,,
177
184
1,"Empty columns named 'b', '', ''! Try: csvcut -C 2,4,5",,,,,
178
185
179
-
Use:doc:`csvcut` to exclude the empty columns:
186
+
Then, use:doc:`csvcut` to exclude the empty columns:
180
187
181
-
.. code-block:: bash
188
+
.. code-block:: console
182
189
183
190
$ csvcut -C 2,4,5 examples/test_empty_columns.csv
184
191
a,c
185
192
a,
186
193
,c
187
194
,
188
195
196
+
Check whether any errors found:
197
+
198
+
.. code-block:: console
199
+
200
+
$ if [ csvclean -a examples/bad.csv ]; then echo "my message"; fi
201
+
my message
202
+
203
+
Or:
204
+
205
+
.. code-block:: console
206
+
207
+
$ [ csvclean -a examples/bad.csv ] && echo "my message"
208
+
my message
209
+
210
+
Or:
211
+
212
+
.. code-block:: console
213
+
214
+
$ csvclean -a examples/bad.csv >/dev/null 2>&1
215
+
$ echo $?
216
+
1
217
+
218
+
Count the number of errors found:
219
+
220
+
.. code-block:: console
221
+
222
+
$ csvclean -a examples/bad.csv 2>&1 >/dev/null | csvstat --count
223
+
2
224
+
225
+
View only the errors found:
226
+
227
+
.. code-block:: console
228
+
229
+
$ csvclean -a examples/bad.csv 2>&1 >/dev/null
230
+
line_number,msg,column_a,column_b,column_c
231
+
1,"Expected 3 columns, found 4 columns",1,27,,I'm too long!
232
+
2,"Expected 3 columns, found 2 columns",,I'm too short!
233
+
189
234
To change the line ending from line feed (LF or ``\n``) to carriage return and line feed (CRLF or ``\r\n``) use:
0 commit comments