Re: CSV to MyDB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I see. Thank you for that and thank you for the link.

Best,
Karl

Sent from losPhone

On Feb 25, 2011, at 10:57 AM, "Adriano Rodrigo Guerreiro Laranjeira" <adriano@xxxxxxxxxxx > wrote:

Hey friend!

You can create a DB table with the same structure of your CSV and store it like a normal table, using the mysqlimport command:
http://dev.mysql.com/doc/refman/5.5/en/mysqlimport.html

In this way, you can do SELECT's and all DML commands.

If you want to store the file as you receive it, that'd be good to create three columns: an ID (AUTONUM), a "date_load" and a BLOB field called "content", where I'd store the CSV. And I guess you should use BLOB. A quote from http://dev.mysql.com/doc/refman/5.0/en/blob.html: "BLOB values are treated as binary strings (byte strings). They have no character set, and sorting and comparison are based on the numeric values of the bytes in column values. TEXT values are treated as nonbinary strings (character strings). They have a character set, and values are sorted and compared based on the collation of the character set."


My $0.02,
Adriano Laranjeira.
SÃo Bernardo do Campo - Brazil.
> > > > > > > On Fri, 25 Feb 2011 09:06:47 -0600
Karl DeSaulniers <karl@xxxxxxxxxxxxxxx> wrote:
Hello everyone,
Hope your day is going well.
I have a (hopefully) quick question. What is the best way to store a CSV file in a MySQL database?
As a varchar, blob, longtext or other?
I would like to minimize the amount of fields in the table, so I was
leaning towards a longtext or blob. But I don't know the advantages or disadvantages to using these. The text is a excel price list that is exported to a csv and the data will be sent to repopulate a html table that has the same amount of fields. the only catch is some of the fields are descriptions (text) and some are just prices (numbers).
Hope this is not an overload of info, just want to inform complete.
TIA,
Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux