[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 249
  • Last Modified:

Need help with a tab delimited file with line feeds in quoted fields

I have a tab delimited file that contains a field that contains a line feed in it.  The column is delimited with the escape char(34).  I am tring to split the array with the chr(9) as the command imp_arr = split(imp_rec,chr(9),-1,1).

The problem is if I have a record that looks like fieldone Chr(9) fieldtwo chr(9)chr(34)This is a chr(10)chr(13)new line chr(34) chr(9)

The resulting split command has only the array as
array(0)=fieldone
array(1)=fieldtwo
array(2)=This is a
with the next arry as
array(0)=new line

Is there a way to get the array to be
array(0)=fieldone
array(1)=fieldtwo
array(2)=This is a new line

Thanks
0
Bizzuka IT
Asked:
Bizzuka IT
  • 2
  • 2
1 Solution
 
TaconvinoCommented:
This is kind of confusing... if you need to get rid of the chr(10)chr(13) sequence, you can do something like this:

imp_arr = split(replace(imp_rec, vbCrLf, ""),chr(9),-1,1)

TCV
0
 
Bizzuka ITAuthor Commented:
The real problem was in the textobject.readline, the VB fuction stopped reading the text line when it came upon the chr(13)chr(10)

Sorry for the confussion...

So I need a way to read the entire file and know when I have a new record versus a chr(13)chr(10) within a field of a record.  (each chr(13)chr(10) outside of the chr(34) pair is a new line....

Thanks
0
 
TaconvinoCommented:
I see... assuming that your textobject is a TextStream object, you can use the ReadAll method to read the entire content into a variable.  After that, I think it would be safe to assume that a chr(34)chr(10)chr(13) sequence is marking the end of your record, so you can split your variable using this sequence, as in:

varAll = textobject.ReadAll
arrRecords = split(varAll, chr(34) & vbCrLf)

So, you end up with an array containing all records.  After this, you can use your original split chr(9) to sepparate your individual values.

But remember!  You last column will always be missing the chr(34) character!

Hope this helps!

TCV
0
 
Bizzuka ITAuthor Commented:
I think that your solution will fix my problem
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now