LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   MySQL imports csv file and appends quote marks - how to remove? (http://www.linuxquestions.org/questions/linux-software-2/mysql-imports-csv-file-and-appends-quote-marks-how-to-remove-791456/)

tensigh 02-25-2010 05:17 AM

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.

rweaver 02-25-2010 11:06 AM

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?

tensigh 02-25-2010 03:57 PM

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!

rweaver 03-03-2010 11:45 AM

You can use 's/string/replace/g' to get all of them on the line instead of just the first.

tensigh 03-03-2010 06:01 PM

Thanks for what you sed
 
Quote:

Originally Posted by rweaver (Post 3884173)
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.)

rweaver 03-04-2010 01:15 PM

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

tensigh 03-04-2010 05:37 PM

Thanks for the tip
 
Quote:

Originally Posted by rweaver (Post 3885864)
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?


All times are GMT -5. The time now is 01:11 AM.