473,320 Members | 2,073 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Split Function

Hey guys,

Very common task: read a csv file. My data reads as:
"1","2","3",

my code reads this way:

While filename.Peek > -1
instr = filename.ReadLine
indata = Split(instr, ",")
End While

Problem: my values are coming out as ""1""

What's my solution?

Thanks
Nov 20 '05 #1
4 17336
"mannyGonzales" <mg*******@bertlingusa.com> schrieb im Newsbeitrag
news:1f*****************************@phx.gbl...
Very common task: read a csv file. My data reads as:
"1","2","3",

my code reads this way:

While filename.Peek > -1
instr = filename.ReadLine
indata = Split(instr, ",")
End While


indata = Split(instr.Replace("""", ""), ",")

Jürgen Beck
MCSD.NET, MCDBA, MCT
www.Juergen-Beck.de
Nov 20 '05 #2
"mannyGonzales" <mg*******@bertlingusa.com> scripsit:
Very common task: read a csv file. My data reads as:
"1","2","3",

my code reads this way:

While filename.Peek > -1
instr = filename.ReadLine
indata = Split(instr, ",")
End While

Problem: my values are coming out as ""1""


You can use 'Replace' to to get rid of the """, or 'Mid' to cut out the
data part of the string. There are lots of other ways to cope with the problem...

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
mannyGonzales,
In addition to the others comments, I used String.Trim to remove the leading
& trailing quote marks on the string after I did the split in a project I
worked on.

indata = instr.Split(","c)
For index As Integer = 0 To indata.Length -1
indata(index) = indata(index).Trim(""""c)
Next

Not sure why I did the above as opposed to using Replace on the input to
Split. Note my project used the String.Split function that accepts a Char,
rather than the VB Split function that accepts a string.

Hope this helps
Jay
"mannyGonzales" <mg*******@bertlingusa.com> wrote in message
news:1f*****************************@phx.gbl...
Hey guys,

Very common task: read a csv file. My data reads as:
"1","2","3",

my code reads this way:

While filename.Peek > -1
instr = filename.ReadLine
indata = Split(instr, ",")
End While

Problem: my values are coming out as ""1""

What's my solution?

Thanks

Nov 20 '05 #4
Great!
Thanks guys i'll be storing this in my data files.
Nov 20 '05 #5

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

Similar topics

5
by: Arjen | last post by:
Hi All, What I want to is using a string as PATTERN in a split function. This makes it possible for me to change the PATTERN on one place in my script... For example: $separator = ";"; $line...
2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
4
by: Henry Chen | last post by:
Hi, I have a string that needs to be parsed into the string. The separator is not char. It is something like " at ". With current string.Split function, it doesn't work. Is there any exist...
5
by: Vamsi | last post by:
Hi, I am trying a basic opearation of splitting a multiline value to an array of single lines(Actually making Address into AddressLine1, AddressLine2). I used Environment.NewLine in split, I...
10
by: mb | last post by:
I was wondering if there is an easy, more useful Split function that will split with a string delimiter like "<>" or "////"?
4
by: Itzik | last post by:
can i split this string string str = "aa a - bb-b - ccc" with this delimiter string del = " - " i want recieve 3 items : "aa a" , "bb-b" , "ccc"
3
by: Ben | last post by:
Hi I am creating a dynamic function to return a two dimensional array from a delimeted string. The delimited string is like: field1...field2...field3... field1...field2...field3......
5
by: sck10 | last post by:
Hello, I have a list of email addresses that I need to send email to from the website. I am trying to use the "Split" function to get all the To's and then use the uBound function for the...
7
by: Jordi Rico | last post by:
Hi, I know I can split a string into an array doing this: Dim s As String()=Regex.Split("One-Two-Three","-") So I would have: s(0)="One" s(1)="Two"
1
by: John | last post by:
Hi I have written a Split function which in turn calls the standard string split function. Code is below; Function Split1(ByVal Expression As String, Optional ByVal Delimiter As String = " ",...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.