简体   繁体   中英

How to skip intermediate rows when importing .csv to MySQL

I need to import standardized .csv files into a MySQL database, but the files need to be cleaned up before they're turned into tables (remove repeating headers, dates, etc.). Each .csv file is exactly 111 lines and has the same spacing and formatting, so I'd like to build a SQL command that skips the appropriate rows in each file and imports the rest into a table.

Is it possible to do this? I know I can 'IGNORE 1 ROWS' to get past the first row(s), but what about rows further down?

Sorry, in the comment you cant see the ticks

You can do it with 1 line of shell script:

line=`head -n 1 standardized.csv`; grep -v "$line"  standardized.csv > new_standardized.csv 

and then import the new_standardized,csv

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM