Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Handling CSV Files

I have a CSV file that contains text data extracted from a
main systems server around 3,000 rows. The data can have
the values illustrated below......

Field1,Field2,+Next,LastField

My problem concerns the +Next value. When I open this is
Excel the +Next is treated as a formula, and it tries to
associate with a named range (presumably called Next).
The cell displays #NAME? since this is clearly not valid
or intended. Subsequent processing of the file causes an
error.

So far my ideas are.....
Load the CSV and trawl through it looking and replacing
text values begining with a + sign (I guess in the general
case I would need to include the - sign and the = sign)
with the text equivalent, I do not want to loose the +
sign from the text.

Or

As I process each record / field I test for this condition
and adjust the value accordingly.

I believe the 2nd option would be preferrable and faster,
since I might only have this situation very rarely.

Can I ask for comments on the proposed solutions or
alternatives if there is something more appropriate.

TIA
Nigel

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 493
Default Handling CSV Files

one way:

If you use the Text Import wizard (you may need to rename the .csv
extension to .txt) you can, in the third tab, choose the third
column and select the Text radio button. Then XL will not try to
parse that column.

You could use a macro as well:

Public Sub readTextFile()
Workbooks.OpenText _
FileName:="<your path<your file name.txt", _
DataType:=xlDelimited, _
comma:=True, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 2), Array(4, 1))
End Sub




In article ,
"Nigel" wrote:

I have a CSV file that contains text data extracted from a
main systems server around 3,000 rows. The data can have
the values illustrated below......

Field1,Field2,+Next,LastField

My problem concerns the +Next value. When I open this is
Excel the +Next is treated as a formula, and it tries to
associate with a named range (presumably called Next).
The cell displays #NAME? since this is clearly not valid
or intended. Subsequent processing of the file causes an
error.

So far my ideas are.....
Load the CSV and trawl through it looking and replacing
text values begining with a + sign (I guess in the general
case I would need to include the - sign and the = sign)
with the text equivalent, I do not want to loose the +
sign from the text.

Or

As I process each record / field I test for this condition
and adjust the value accordingly.

I believe the 2nd option would be preferrable and faster,
since I might only have this situation very rarely.

Can I ask for comments on the proposed solutions or
alternatives if there is something more appropriate.

TIA
Nigel

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Handling CSV Files


Thanks, I have now incorporated the approach and we are in
business again!
Cheers
Nigel
-----Original Message-----
one way:

If you use the Text Import wizard (you may need to rename

the .csv
extension to .txt) you can, in the third tab, choose the

third
column and select the Text radio button. Then XL will not

try to
parse that column.

You could use a macro as well:

Public Sub readTextFile()
Workbooks.OpenText _
FileName:="<your path<your file name.txt", _
DataType:=xlDelimited, _
comma:=True, _
FieldInfo:=Array(Array(1, 1), Array(2, 1), _
Array(3, 2), Array(4, 1))
End Sub




In article ,
"Nigel" wrote:

I have a CSV file that contains text data extracted

from a
main systems server around 3,000 rows. The data can

have
the values illustrated below......

Field1,Field2,+Next,LastField

My problem concerns the +Next value. When I open this

is
Excel the +Next is treated as a formula, and it tries

to
associate with a named range (presumably called Next).
The cell displays #NAME? since this is clearly not

valid
or intended. Subsequent processing of the file causes

an
error.

So far my ideas are.....
Load the CSV and trawl through it looking and replacing
text values begining with a + sign (I guess in the

general
case I would need to include the - sign and the = sign)
with the text equivalent, I do not want to loose the +
sign from the text.

Or

As I process each record / field I test for this

condition
and adjust the value accordingly.

I believe the 2nd option would be preferrable and

faster,
since I might only have this situation very rarely.

Can I ask for comments on the proposed solutions or
alternatives if there is something more appropriate.

TIA
Nigel

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling Large Files RJB Excel Discussion (Misc queries) 3 July 15th 08 04:30 AM
Error Handling Kevin Excel Discussion (Misc queries) 4 June 19th 08 12:31 AM
Handling #NUM! error Michel Khennafi Excel Worksheet Functions 1 February 26th 07 08:49 PM
Error handling John Pierce Excel Programming 3 October 3rd 03 12:17 PM
Error Handling Rob Bovey Excel Programming 0 August 7th 03 12:11 AM


All times are GMT +1. The time now is 11:27 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"