Jump to content

phpmyadmin, import CSV-load date with line breaks?


michel225

Recommended Posts

Hallo

 

I have the following problem.

I have a CSV file with articles (for joomla) that I want to import to my server through phpmyadmin. Now after figuring out how to import date format i came across my second problem, and that is how to import the articles that is stored in a cell that is in a csv-load date file????

The problem is that when importing it, I don't see any line breaks in the articles, not in joomla and not in the html code that sould be stored in phpmyadmin.

(In the CSV file I see line breaks, just like when copying it to word, but not on the server)

So I hope that somebody can help me with that Thanks in advance

Link to comment
Share on other sites

thanks for answering 

 

It's not that i'm looking for html codes but want in the date that i put in the server to have break lines (so <br > or <p >) 

When importing date with a CSV Load-Date file thourgh phpmyadmin, you have a function that automatically detects line breaks en converts them to <p > or <br > html codes (I think) but it doesn't seem to work when I do that???

Link to comment
Share on other sites

I don't understand what you mean. Yo cannot arbitrarily replace newlines with BR tags, that would break all your data.

 

I'd suggest that you should import the CSV without making any replacements using phpmyadmin (which is a *crappy* tool anyway) and use UPDATE queries on the columns where you want to replace newlines with BR tags.

Link to comment
Share on other sites

I had a feeling you were new to the whole  SQL thing :-)

 

First a warning;  replacing newlines with BR tags in the HTML is usually not a good idea because a newline formats the HTML source, whereas a BR tag formats the rendered HTML page.

If the source contains "<br>\n"  (this is very common in html) then you definately do not want to replace that with "<br><br>" because your page would look different. What's more, you cannot go back to "<br>\n" because of the same reason.

 

You have been warned.

 

That said; replacing a string "\n" with "<br>" in the column named "your_column_name" in the table named "your_table" is as simple as this:

 

UPDATE your_table SET your_column_name = REPLACE(your_column_name, "\n", "<br>");

 

See also: dev.mysql.com/doc/refman/5.0/en/string-functions.html#function_replace

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.