VB.NET - Converting a .csv file to mysql table

Asked By sam son on 31-Mar-08 03:17 AM
Hello could any1 helps me to convert .CSV file as MySQL table.

Converting a .csv file to mysql table - Shailendrasinh Parmar replied to sam son on 31-Mar-08 03:30 AM

Here are two good links to convert .csv file to mysql table... just have a look... hope it helps...

http://convert-csv-to-sql.qarchive.org/
http://www.perlmonks.org/?node_id=176972

Converting a .csv file to mysql table - sam son replied to Shailendrasinh Parmar on 31-Mar-08 03:49 AM

Hello Sanjay Verma thanks for ur help, but could i get little clear ? in the second link as u sent does it required perl ? hey cud i have a sample kind of example for taking a .csv file and converting that as mysql table if necessary to modify little bit in the .csv file and finally that would effect on mysql table using vb.net application. I know its little difficut but i hope that u guys do it ! hoping 

Thanks

Sam  

try this.. - Santhosh N replied to Shailendrasinh Parmar on 31-Mar-08 04:36 AM

check this article for doing it...it is in vb.net

http://www.thescripts.com/forum/thread755637.html

csv to mysql table - sundar k replied to sam son on 31-Mar-08 04:52 AM

Import Unicode CSV files to MySQL

Unicode UTF-8 comma-separated values (CSV) text files, which are exported or generated by such applications as Microsoft Access or Excel, can be imported to MySQL via LOAD DATA INFILE command.

The import will be executed as follows:

mysql> LOAD DATA LOCAL INFILE 'authors.txt' INTO TABLE authors FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

for a CSV file 'authors.txt' with records having data fields as follows:

"authid","lastname","firstname","address","city","country","phone","email"
1,"Nguyễn","Trần","Lý Thường Kiệt","Sài Gòn","Việt Nam","848-999-9999","nguyentran@yahoo.com"
2,"Lê","Lý","Phố Quang Trung","Hà Nội","Việt Nam","848-888-8888","lely@yahoo.com"

The line terminator '\r\n' is for Windows systems; for Unix/Linux, '\n' is used.

You have one more option also mysqlimport — A Data Import Program, The mysqlimport client provides a command-line interface to the LOAD DATA INFILE SQL statement.

Check out the below link for more info,

http://dev.mysql.com/doc/refman/5.0/en/mysqlimport.html

Converting a .csv file to mysql table - Shailendrasinh Parmar replied to sam son on 31-Mar-08 05:04 AM

Hi Sam,

I don't know much about perl, but in the second link there is a link for downloading the code sample...

you can try this and use it in your application...

mysql> LOAD DATA LOCAL INFILE 'authors.txt' INTO TABLE authors FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n'; whats the table name and where it is going to be stored ?
sam son replied to sundar k on 31-Mar-08 06:15 AM

Hello Sunder where the table is going to formed when i execute this in: mysql> LOAD DATA LOCAL INFILE 'authors.txt' INTO TABLE authors FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\r\n';

Seems it has executed ... now i want to see the table where it has formed .. ? and may i know what would be the table name ? please let me know am looking forward to hear from you and thank you very much for your help so far..

Sam


table... - sundar k replied to sam son on 31-Mar-08 11:26 AM

just check your LOAD DATA statement for "INTO TABLE authors" text, I hope you got it now, its getting inserted into authors table, i.e. your table name will be authors. If you want to know more about the syntax, just check out the MySQL site,

http://dev.mysql.com/doc/refman/5.0/en/load-data.html

hope it helps!