472,958 Members | 1,945 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Import/export problem with CSV/PHP/MySQL

Hi to all,
I need to design an import/export system. Data comes from a filemaker
pro DB in a big CSV file. Some alterations are made on the data as it is
imported into my mysql table. Data is something like :id,text1html,
text1raw,... .

Problems :
1. Texts can contain html tags, including entities (" etc), so
using only the ';' as separator does not work.
2. Some line are so long that is appears php breaks them down, so I lose
data reading the file.

For 1, I've come across fgetcsv() in recent posts. Works fine for now.

For 2, I can't seem to find a solution. I've tried to detect "broken"
lines and stick them back together but no effect...

Another problem arises when I try to export the data back into CSV, as
it is suposed to be used in Excel. The CR/LF that are in the text are
logically interpreted as new rows in Excel. How can I get around this ?
Is there a special "new line" character that excel would not interpret
as new row ? Should I try another file format ?

Thanks in advance for any idea/hint/link !

BR,
Damien
---
"So you're just taking your caffeine level past the medical definition
of 'stimulant' into the 'poisons' category?"
Bastard Operator From Hell
Jul 17 '05 #1
2 12346
Damien <tr**@bidule.net> wrote in message news:<41***********************@news.free.fr>...
Hi to all,
I need to design an import/export system. Data comes from a filemaker
pro DB in a big CSV file. Some alterations are made on the data as it is
imported into my mysql table. Data is something like :id,text1html,
text1raw,... .

Problems :
1. Texts can contain html tags, including entities (&quot; etc), so
using only the ';' as separator does not work.
Usually, CSV should be comma separated.
2. Some line are so long that is appears php breaks them down, so I lose
data reading the file.
For CSV -> MySQL import use LOAD DATA INFILE
<http://dev.mysql.com/doc/mysql/en/LOAD_DATA.html> comment #4964

For MySQL -> CSV, OUTFILE
Another problem arises when I try to export the data back into CSV, as
it is suposed to be used in Excel. The CR/LF that are in the text are
logically interpreted as new rows in Excel. How can I get around this ?
Is there a special "new line" character that excel would not interpret
as new row ?


You may want to look at this usernote to understand CSV format
<http://in.php.net/fgetcsv#14788>

--
<?php echo 'Just another PHP saint'; ?>
Email: rrjanbiah-at-Y!com Blog: http://rajeshanbiah.blogspot.com/
Jul 17 '05 #2
R. Rajesh Jeba Anbiah a écrit :
Usually, CSV should be comma separated.
Except when the data provider is French and no much competent than me ;o)

2. Some line are so long that is appears php breaks them down, so I lose
data reading the file.

For CSV -> MySQL import use LOAD DATA INFILE
<http://dev.mysql.com/doc/mysql/en/LOAD_DATA.html> comment #4964

For MySQL -> CSV, OUTFILE


Thanks for the tip, I didn't even think about this function...

I actually found out that I had set a too low limit for the line length
in fgetcsv()... D'oh...

(snip)
You may want to look at this usernote to understand CSV format
<http://in.php.net/fgetcsv#14788>


I had read these comments in another post, and it didn't work : excel
displays a "square" character. Until I found that the "square"
disappears when you set the cell format to "wrap text"...

Thanks for the links, that's been very helpfull !

BR,
Damien
---
"Disk that's so old it's got marks from Noah's screwdriver on the side."
BOFH
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: Bruce A. Julseth | last post by:
Newbie Question: Is there a way to import MS Access into MySQL? Maybe create a CSV or something. If so, what would be the SQL to do this? Thanks... Bruce
0
by: Vidhya CS | last post by:
Hi , I am trying to export a database from one machine ie linux, and import the same database to another machine ie ,solaris . I exported the database using the following command . mysqldump...
2
by: Brian Huether | last post by:
I saved my website databgase to my home computer. I am setting up a local version of the site, and need to import the database. I have mysql and everything set up. But when I try to run the sql...
4
by: news | last post by:
Our production database in an exported textfil runs about 60 MB. Compressed that's about 9 MB. I'm trying to import the export into another machine running FC3 and mySQL 11.18, and it appears as...
5
by: Kajol | last post by:
Hi All, can u plz tell me how to import data from mysql to another database. & how to export data from anotherdata base to mysql Thanx for ur Advice Regards Kajol
1
by: Martin Herrman | last post by:
Hi all, I have installed MySQL on my Linux Mandrake 10 workstation; I didn't change any default values (except for the user-accounts). I used a CMS to create a website which I want to upload to...
7
by: phillip.s.powell | last post by:
We're looking at a GUI interface for our MySQL DB and I am interested in MySQL Administrator, however, one of our requirements is to be able to import/export databases. Is this possible or do I...
10
by: Simon | last post by:
Hi, I need to export a 200MB database from one domain to another. phpMyAdmin timeout after a while and is not ideal. I don't mind spending money if I have to but this is rather urgent. I...
7
by: Randy | last post by:
Folks: We have a web-based app that's _really_ slowing down because multiple clients are writing their own private data into a single, central database. I guess the previous programmer did...
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.