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

How to read and split file as string

14
Hi,
I'm not very familiar how to do this in C#. Need to connect to Oracle db, take a file from directory then read every line of the file. Lines are like this:

123234847656|8800359898818177|A|20130401 14:51:42|
123234847212||D|20130401 14:52:08|
123234847212||M|20130401 14:55:38|

Then will split as string on every '|' char and according to this flag |A|, |D| or |M| I will add/delete/modify information inside. I have trouble with this part with the connection and read/split file and check for the flag A, D or M.
Thanks in advance!
Apr 16 '13 #1

✓ answered by Rabbit

You can use the string.split method to separate your line by a delimiter into an array. Then you just need to check the third element in the array to see if it's A, D, or M.

Here is Microsoft's documentation on the split method: http://msdn.microsoft.com/en-us/libr...code-snippet-1

2 2507
Rabbit
12,516 Expert Mod 8TB
You can use the string.split method to separate your line by a delimiter into an array. Then you just need to check the third element in the array to see if it's A, D, or M.

Here is Microsoft's documentation on the split method: http://msdn.microsoft.com/en-us/libr...code-snippet-1
Apr 16 '13 #2
try like this

str = "123234847212||D|20130401 14:52:08|";
char[] splitchar = { '|' };
strArr = str.Split(splitchar);

http://csharp.net-informations.com/s...ring-split.htm

nicol.
Apr 18 '13 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Krish | last post by:
I have requirement, that i get one big chunk of text file. This text file will have has information, that on finding "****End of Information****", i have to split them individual text file with our...
4
by: Crirus | last post by:
There is a function somewhere to split a string with multiple tokens at a time? Say I have this: aaaa#bbbbb*ccccc$dddd I whould like to split it so the result whould be aaaa bbb
4
by: michael.bollhoefer | last post by:
I am trying to split a string into two different variables. The string is pulled from an XML file from a WEBDAV program. The string will be in this form "John Doe" <john.doe@webserver.com> ...
2
by: Digital Fart | last post by:
following code would split a string "a != b" into 2 strings "a" and "b". but is there a way to know what seperator was used? string charSeparators = { "=", ">=", "<=" , "!=" }; string s1 =...
12
by: Pascal | last post by:
hello and soory for my english here is the query :"how to split a string in a random way" I try my first shot in vb 2005 express and would like to split a number in several pieces in a random way...
24
by: garyusenet | last post by:
I'm working on a data file and can't find any common delimmiters in the file to indicate the end of one row of data and the start of the next. Rows are not on individual lines but run accross...
6
by: portCo | last post by:
Hello there, I am creating a vb application which is some like like a questionare. Application read a text file which contains many questions and display one question and the input is needed...
8
by: Jromero | last post by:
My code Another class = new Student; /* public static void copyLines() throws IOException { BufferedReader inputStream = null; PrintWriter outputStream = null; ...
5
by: dm3281 | last post by:
Hello, I have a text report from a mainframe that I need to parse. The report has about a 2580 byte header that contains binary information (garbage for the most part); although there are a...
1
by: ywang123 | last post by:
I have a test.csv file with multi line in one field like following: Name, message "Gus", "See you" "Amy", "take to you later, Thank you. call me" "Mark", "Try it...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.