Importing CSV files to MySql Db issue.

Importing CSV files to MySql Db issue.

am 16.02.2008 05:13:59 von Chris Carter

Is there something that has changed in the new MySql DB ?

I am trying to upload a data like this from my CSV file to a table through
CSV upload and not CSV Load Data:

field1,field2,field3,field4,field5,field,6,field7,field8
field1,field2,field3,field4,field5,field,6,field7,field8

Parameters I am using are:

Fields Terminated By: ,
Fields Enclosed By: _ (space character)
Fields Escaped By: _ (space character)

Every time I am getting this error: Invalid field count in line 1

Is there any other workaround for this.

Please suggest,

Thanks,

Chris
--
View this message in context: http://www.nabble.com/Importing-CSV-files-to-MySql-Db-issue. -tp15514806p15514806.html
Sent from the Php - Database mailing list archive at Nabble.com.

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

Re: Importing CSV files to MySql Db issue.

am 18.02.2008 00:07:20 von dmagick

Chris Carter wrote:
> Is there something that has changed in the new MySql DB ?

What new mysql? Has your host upgraded your database version or something?

Mysql won't change the interface between versions except to improve it.

> I am trying to upload a data like this from my CSV file to a table through
> CSV upload and not CSV Load Data:

Eh? You're using the csv table type or how are you importing the data?

> field1,field2,field3,field4,field5,field,6,field7,field8
> field1,field2,field3,field4,field5,field,6,field7,field8
>
> Parameters I am using are:
>
> Fields Terminated By: ,
> Fields Enclosed By: _ (space character)
> Fields Escaped By: _ (space character)
>
> Every time I am getting this error: Invalid field count in line 1

If you're using spaces for enclosing then I'm sure you're not handling
something properly.

Chris,Carter,email@address.com <-- 3 records
Chris Carter,email@address.com <-- 2 records

The second one is probably going to break because of the space in the
middle of the name.

--
Postgresql & php tutorials
http://www.designmagick.com/

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

RE: Importing CSV files to MySql Db issue.

am 18.02.2008 00:38:27 von Gary Wardell

Chris,

> If you're using spaces for enclosing then I'm sure you're not
> handling
> something properly.
>
> Chris,Carter,email@address.com <-- 3 records
> Chris Carter,email@address.com <-- 2 records
>

Don't you mean:

Chris,Carter,email@address.com <-- 3 *fields*
Chris Carter,email@address.com <-- 2 *fields*

And both only result in one record for each CSV line?

Or do PHP and MySql handle CSV files different from most other applications?

Gary

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

Re: Importing CSV files to MySql Db issue.

am 18.02.2008 00:42:47 von dmagick

Gary Wardell wrote:
> Chris,
>
>> If you're using spaces for enclosing then I'm sure you're not
>> handling
>> something properly.
>>
>> Chris,Carter,email@address.com <-- 3 records
>> Chris Carter,email@address.com <-- 2 records
>>
>
> Don't you mean:
>
> Chris,Carter,email@address.com <-- 3 *fields*
> Chris Carter,email@address.com <-- 2 *fields*
>
> And both only result in one record for each CSV line?

Ah yes - sorry about that :)

--
Postgresql & php tutorials
http://www.designmagick.com/

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

Re: Importing CSV files to MySql Db issue.

am 18.02.2008 05:46:17 von Chris Carter

I am not using spaces for closing. Every field is tightly packed with comma
only. No spaces, no semicolon. The reason I used space is if I use space at
least 3 or 4 fields get uploaded but not all. But we can ignore space for
now as it happened earlier.

I am using the CSV import option from MySql admin.

Still stuggling,

Thanks,

Chris



chris smith-9 wrote:
>
> Chris Carter wrote:
>> Is there something that has changed in the new MySql DB ?
>
> What new mysql? Has your host upgraded your database version or something?
>
> Mysql won't change the interface between versions except to improve it.
>
>> I am trying to upload a data like this from my CSV file to a table
>> through
>> CSV upload and not CSV Load Data:
>
> Eh? You're using the csv table type or how are you importing the data?
>
>> field1,field2,field3,field4,field5,field,6,field7,field8
>> field1,field2,field3,field4,field5,field,6,field7,field8
>>
>> Parameters I am using are:
>>
>> Fields Terminated By: ,
>> Fields Enclosed By: _ (space character)
>> Fields Escaped By: _ (space character)
>>
>> Every time I am getting this error: Invalid field count in line 1
>
> If you're using spaces for enclosing then I'm sure you're not handling
> something properly.
>
> Chris,Carter,email@address.com <-- 3 records
> Chris Carter,email@address.com <-- 2 records
>
> The second one is probably going to break because of the space in the
> middle of the name.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

--
View this message in context: http://www.nabble.com/Importing-CSV-files-to-MySql-Db-issue. -tp15514806p15538890.html
Sent from the Php - Database mailing list archive at Nabble.com.

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

Re: Importing CSV files to MySql Db issue.

am 18.02.2008 05:53:11 von dmagick

Chris Carter wrote:
> I am not using spaces for closing. Every field is tightly packed with comma
> only. No spaces, no semicolon. The reason I used space is if I use space at
> least 3 or 4 fields get uploaded but not all. But we can ignore space for
> now as it happened earlier.

Then your issue will be a comma in your data.

Header: Company Name, Name
#1: Widget Co, Chris
#2: Widget Co, New York, Chris

#1 will work fine.

#2 will be seen as
"company name" -> "Widget Co"
"Name" -> "New York"

Extra data -> "Chris" at the end.

Enclose your entries with something (" or ' or ~ or something else
that's not going to be in your data).


--
Postgresql & php tutorials
http://www.designmagick.com/

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