如何使用C ++将csv文件数据存储到mysql表中?

时间:2022-02-28 17:00:48

The file content like this

像这样的文件内容

'COGT','COGT','COGENT ORD'
'COG','COG','CABOT OIL & GAS ORD'
'COGZF','COGZF','COGSTATE ORD'
'COHG','COHG','CHEETAH OIL & GAS ORD'
'COHIQ','COHIQ','COHO ENERGY ORD'
'COHM','COHM','ALL AMERICAN GROUP ORD'
'COHN','COHN','COHEN ORD'
'COHR','COHR','COHERENT '

But i need to get it into a mysql database contain columns name,description you can also see first and second same so i want only one for name 3rd for description My espected output like

但是我需要把它变成一个包含列名的mysql数据库,描述你也可以看到第一个和第二个相同所以我只想要一个名字第3个描述我想到的输出像

NAME   |      DESCRIPTION
cogt   |      cogt ord
cog    |      cabot oil

if you have any idea kindely share to me

如果你有任何想法kindely分享给我

1 个解决方案

#1


4  

You can then import it into a MySQL table by running:

然后,您可以通过运行以下命令将其导入MySQL表:

load data local infile 'input_file.csv' into table tblUniq fields terminated by ','
enclosed by '"'
lines terminated by '\n'
(NAME, DESCRIPTION)

#1


4  

You can then import it into a MySQL table by running:

然后,您可以通过运行以下命令将其导入MySQL表:

load data local infile 'input_file.csv' into table tblUniq fields terminated by ','
enclosed by '"'
lines terminated by '\n'
(NAME, DESCRIPTION)