LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
Search this Thread
Old 02-25-2010, 05:17 AM   #1
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 141

Rep: Reputation: 15
MySQL imports csv file and appends quote marks - how to remove?


Hello,

I'm importing a csv file into a MySQL table, and it works perfectly, except for the csv file added quote marks on two of the columns when I created it. So the question is;

- What's the best way to remove the quote marks out of the file?

or

- Is there a way to ignore those marks when the file is imported into MySQL?

Any help would be greatly appreciated.
 
Old 02-25-2010, 11:06 AM   #2
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
Could you post the following:

Sample data of the csv, the fields which are having issues, and an example of how they look in mysql when you select the data?
 
Old 02-25-2010, 03:57 PM   #3
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 141

Original Poster
Rep: Reputation: 15
Thanks, I think I figured something out

Thanks for offering help! I think I may have figured something out. I opened the original file and used 'sed' to remove the quotes, substituting the quotes with nothing. I had to run sed 4 times since it would erase the first quote per line, then go on to the next line (I don't know how to use sed very well yet). But this worked, and my file looks perfect.

Thanks for a timely reply!
 
Old 03-03-2010, 11:45 AM   #4
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
You can use 's/string/replace/g' to get all of them on the line instead of just the first.
 
Old 03-03-2010, 06:01 PM   #5
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 141

Original Poster
Rep: Reputation: 15
Thanks for what you sed

Quote:
Originally Posted by rweaver View Post
You can use 's/string/replace/g' to get all of them on the line instead of just the first.
Thanks for the tip. I really need to spend some time learning sed bedder. A lot of the explanations I've red give way too much detail and they get lost in my hed so I often cherry pick parts I needed then discard the rest. So there are parts I've red but there are other parts past which I sped. I think I'll spend a little more time learning sed. (Hey, that almost sounds like Dr. Suess. A very poor rendition, but sounds like that nonetheless.)
 
Old 03-04-2010, 01:15 PM   #6
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 163Reputation: 163
I've found when using sed the sed-one liners page is excellent for figuring out the particulars of how a features works. Once you understand how some of the one liners work you can move on to learning sed in a more methodical manner and it's considerably easier.

Check it out:

Sed One-liners
 
Old 03-04-2010, 05:37 PM   #7
tensigh
Member
 
Registered: Mar 2004
Location: Tokyo, Japan
Distribution: Backtrack 5 R3
Posts: 141

Original Poster
Rep: Reputation: 15
Thanks for the tip

Quote:
Originally Posted by rweaver View Post
I've found when using sed the sed-one liners page is excellent for figuring out the particulars of how a features works. Once you understand how some of the one liners work you can move on to learning sed in a more methodical manner and it's considerably easier.

Check it out:

Sed One-liners
I checked it out, and I've bookmarked it for reference. This type of page is perfect because it applies sed and its switches to real-world examples. I get so frustrated with man pages (or programming books!) that never translate things into real-world examples.

BTW, I checked out your company's main page. Looks like a really great company. Do you find customers leery about switching to Ubuntu or other FOSS platforms or software?
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Update csv file into mysql db via bash script xmrkite Linux - Software 4 01-13-2010 12:43 AM
Importing a csv file into a mysql database kaplan71 Linux - Server 13 09-18-2009 06:13 PM
Remove every fourth line from CSV file? briana.paige Linux - Newbie 3 08-12-2009 10:07 AM
Comparing two csv files and write different record in third CSV file irfanb146 Linux - Newbie 3 06-30-2008 09:15 PM
bash script - remove header row from csv file pljvaldez Programming 5 08-30-2006 11:05 AM


All times are GMT -5. The time now is 11:46 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration