Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...This was the ONLY place that I could find information that I could use to resolve the problem. So thanks once again to member TomSark and the SQL forum!..."

Geography

Where in the world do Tek-Tips members come from?

Import CSV to Excel 2010 does not work correctly

Parcival21 (TechnicalUser)
15 Jun 12 10:44
Hi all,

I have a problem when converting an CSV into a xls file.
I have narrowed down the problem to the following:
The last column in the csv is a text field which contains several carriage returns.
Problem is now that as soon as the carriage return is detected a new line is started and the text is written in the first column again.
Replacing all carriage returns is also not an option because then it will write only one line in total.

Funny thing is that Excel 2003 on another PC does the translation perfectly but it is not working with Excel 2010 on my PC (and that is one requirement I have).

Is there any option I can use to transform this?
Any ideas? Doing some search/replace upfront would actually not be an issue for me.

BR
Tobias
kjv1611 (TechnicalUser)
15 Jun 12 10:53
How comfortable are you with VBA? There may be an easier route, but that may be the best route. Iniitially, I was thinking you could do a find/replace in the text file format of the carraige returns, but I don't really think that will work. My thought was replace one carriage return with two. However, that will still likely give you 2 records, I'm guessing.

But using VBA, you could read from and write to text. So...

You could use VBA to control the line breaks, etc, and then copy in the text, field by field, cell by cell... or perhaps row by row, not sure if it would work with this one (row by row)..

Here's a blog post talking about the very idea that I'm mentioning:
http://vbadud.blogspot.com/2007/06/vba-read-text-f...

And here's another with a module setup that you can just copy/paste in, and start using it, basically:
http://www.exceluser.com/explore/questions/vba_tex...

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57

SkipVought (Programmer)
15 Jun 12 10:57
hi,

Please explain how you IMPORT the .csv.

If you OPEN the .csv in Excel, you have a problem

If first open Excel, and in an empty workbook, you use Data > Get Extrenal Data > From Text... you will have better control over each column of data.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

kjv1611 (TechnicalUser)
15 Jun 12 11:17
True... make sure you meet Skip's demands first. The other mention is more of an if all else fails approach.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57

SkipVought (Programmer)
15 Jun 12 11:21

Demands? Yikes! Sounds tyranical!!!

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

kjv1611 (TechnicalUser)
15 Jun 12 15:58
BLUSH oops
rofl

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57

Parcival21 (TechnicalUser)
18 Jun 12 4:30
Hey,
Thanks for all the replies.
@SkipVought: I tried that already and it didn't work.
Might need to go with the VBA thing. I will be able to manage that I guess but it will give me a hard time smile.

Only thing I am really confused about is: Why is it working with Excel 2003 and not with Excel 2010? What did they change? That is really confusing for me. I tried a lot already with replacing this and that but in the end I found no algorithm that will really do it.

If there is no other idea I will go with the VBA approach.

Thanks everyone,

BR
Tobias
SkipVought (Programmer)
18 Jun 12 8:31

[quote]and it didn't work.
[/qoute]
Exactly what does that mean
, as there is a whole spectrum of possible interpretations, from ABSOLUTELY not one thing occurred, to the thing that did occur, was somewhat close but not precisely what was expected, in a manner as specified by, and then a description of the result ensues?

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close