473,378 Members | 1,679 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,378 software developers and data experts.

Character separated lines into a collection

Via a TCP/IP socket, I receive two lines of comma separated text. The
first line is always the titles of all the columns. The subsequent
line is the data for each column. How do I split out the titles and
the data, put them in an array or collection of some kind, pull the
data for one of the titles, modify it, and write it back to the same
spot in the array?

Thanks for help,

Chris
Nov 20 '05 #1
1 891
This code makes a two-dimenstional arraylist, or an arraylist of array lists
holding your data

Dim sText As String
Dim aList As New ArrayList

' This is hard-coding the text, you will have got this from the
stream
sText = "A,B" & ControlChars.CrLf & "C,D"

' Create an ArrayList to store each line but splitting the text at
the CrLf
Dim aRows As New ArrayList
aRows.AddRange(sText.Split(ControlChars.CrLf))
' Loop around each row
Dim sRow As String
For Each sRow In aRows
' Add an ArrayList made from splitting each row at the comma
aList.Add(New ArrayList(sRow.Trim.Split(",")))
Next

Debug.WriteLine("First column name is " & CType(aList(0),
ArrayList).Item(0))
Debug.WriteLine("Second column name is " & CType(aList(0),
ArrayList).Item(1))

Debug.WriteLine("First row first column is " & CType(aList(1),
ArrayList).Item(0))
Debug.WriteLine("First row second column is " & CType(aList(1),
ArrayList).Item(1))

"Chris" <cf*****@hotmail.com> wrote in message
news:d9**************************@posting.google.c om...
Via a TCP/IP socket, I receive two lines of comma separated text. The
first line is always the titles of all the columns. The subsequent
line is the data for each column. How do I split out the titles and
the data, put them in an array or collection of some kind, pull the
data for one of the titles, modify it, and write it back to the same
spot in the array?

Thanks for help,

Chris

Nov 20 '05 #2

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

Similar topics

5
by: Wai Yip Tung | last post by:
When I do for line in fp: the line string usually has a '\n' at the end. In many cases I don't want the line break character. I can trim it using if line.endswith('\n'): line = line ...
17
by: Douglas Alan | last post by:
Is there a canonical way of iterating over the lines of a file that are null-separated rather than newline-separated? Sure, I can implement my own iterator using read() and split(), etc., but...
4
by: Raquel | last post by:
Could someone explain to me what the reason is for having a character delimiter (which is double quotes by default) for performing Loads/Imports on UDB? I would think that column delimiter along...
8
by: Dawn Minnis | last post by:
Hey guys If I have a program (see codeSnippet1) that I compile to be called test.o Then run it as test.o n n 2 3 4 I want the code to be able to strip out the two characters at the start...
2
by: Roy Rodsson via .NET 247 | last post by:
Hi all! I am using a stored procedure in SQL2000 for retrieving fileinformations from a db. the table as an uniqueidentifier for the file information. The stored procedure has a variable...
10
by: Jonathan Smith | last post by:
I have a VB app that has a richtextbox with the word wrap set to true. I need to be able to output the text to a text file, but it just puts the text in the file as one long line. How do i...
54
by: MLH | last post by:
I use A97 and do not always insert line numbers while writing procedures. I find it necessary to go back and add them later to aid in debugging. Nearly 3 years ago, something was mentioned in...
8
by: Steve Bergman | last post by:
As I study Python, I am trying to develop good, Pythonic, habits. For one thing, I am trying to keep Guido's the style guide in mind. And I know that it starts out saying that it should not be...
10
by: Paul W | last post by:
Hi all, I have an application that reads data in from a text file and stores it in a database. My problem is that there are some characters in the file that aren't being handled properly. For...
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.