I am using these two strategies for this type of problem:
1) Import all
- import all rows into temporary table where columns have
varchar
type - delete rows you do not want
- insert data into final table, cast
varchar
to desired types
2) Pre-process
- delete rows from imported file
- import
For your case, you can delete 2nd line using sed
for example:
sed -i '2d' importfile.txt
This will remove 2nd line from file named importfile.txt
. Note that flag -i
will overwrite the file immediately, so use it with care.
You can use this to delete range of lines:
sed -i '2,4d' importfile.txt
This will remove lines 2, 3, 4 from file.