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

i am trying to read a 2 way delimited txt file into sqlserver in C# 2008.

9
i am trying to read a 2 way delimited txt file into sqlserver in VS2008 using C# and SQL server2005. the individual entries of the file are delimited by "~" and the data within the entries are separated using "$". and i need to read the entries as rows in the database and the data within each entry i.e. delimited by $ as columns or fields in the database.

since i am new to .net, i am not able to do the 2 way delimiting and read all the rows into the database.

here is a pattern of the data we are dealing with...

************************************************** ******
12:02:16 AM$206.79.184.123$eejyaqmgcm0cdj45apdeeu55$Availab ility$General network error.~
12:02 AM$170.35.208.22$bo1lbm455s1di245asulqrjc$online_b ooking.aspx$Object reference not set to an instance of an object.~

************************************************** ******

as u can see, ~ separates two different entries...i.e to be entered as rows in the database. and $ separates the data within each entry...i.e the columns inside each row in the database.

i would be very thankful if u could help me in this matter as soon as possible.
Jul 16 '10 #1
4 1385
GaryTexmo
1,501 Expert 1GB
Have a look at the String.Split method.

You can use it to tokenize your source string by ~. Then use it again on each token returned by the first split to further tokenize those lines by #.

Also, note that in the second token (by ~) you've got a space in one of the items.. "online_b oooking.aspx" instead of "online_booking.aspx". Typo? Maybe check your source file.

Try playing with String.Split and let us know if you have any questions! :)
Jul 16 '10 #2
indona
9
thanks a lot for the reply. i have just done the reading of the file with the split function by displaying the lines onto cmd. thanks a lot for the help.
but i am still not sure about the part of reading the data into the database. can you plz help me with some sample code for this.
Jul 16 '10 #3
GaryTexmo
1,501 Expert 1GB
Sorry, I'm not overly experienced with working with databases, nor do I have your setup. If it's a DataSet you're putting it into, and each delimited item represents a column, you should be able to tell the column number by the index in the split array.

I dunno if that helps or not...
Jul 16 '10 #4
indona
9
okay.... i will try with d index part u just mentioned..
anyway thanks a lot..
Jul 16 '10 #5

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

Similar topics

3
by: jrlen balane | last post by:
how would i read a tab delimited file? at the same time put what i read in an array, say for example that i know that the file is an array with column= 5 and row=unknown.
1
by: Rob | last post by:
Hi, Sorry if this has been asked before(I searched, but didn't see anything). I need to read a tab delimted file into an array with ASP. Should be easy enough, I know it is in Perl and PHP. Can...
3
by: TF | last post by:
Hi, I have to access data from a comma delimited file in .net windows application (VB.net or C#). I am using Microsoft.Jet.OLEDB.4.0 provider for this purpose. Now the problem is when i extract...
3
by: monte | last post by:
Hello, I need to parse a tilde delimited file and output it to a tabbed delimited file. Example file example.txt data1~data2~data3~data4 data5~data6~data7~data8 I need to extract data2,...
6
by: Skc | last post by:
I am trying to import a file using a custom VB.net procedure, but the problem is it works on a file with pure comma separation and not inverted commas and commas, i.e. it works for AAA,BBB,CCC,DDD...
4
by: Hilary Cotter | last post by:
Thanks for all the help you gave me yesterday. here is another question. I have a comma delimited file called redirect.txt which looks like this test, /test.htm test 123,/test123.htm
1
by: j7.henry | last post by:
I am trying to pull specific data that is in a comma delimited file into a web page. So if my comma delimited file looks like: Name,Address,Zip Fred,123 Elm,66666 Mike,23 Jump,11111 I would...
1
jwwicks
by: jwwicks | last post by:
Hello All, This is a student assignment. So I don't want the complete answer just a hint or maybe a bumb on the head cause I'm doing it the wrong way. Assume I haven't done anything braindead like...
11
by: kimmelsd33 | last post by:
I would like some expert advice. I am writing in VB6. I am opening a tab delimited file, deleting the first 50 lines, and rewriting the file to a temp file. The temp file has about 20 columns with x...
7
by: kimmelsd33 | last post by:
I am using VB6. I want to read a tab delimited file, and assign each column value into a variable. If the variable is "-999.25", I want to make it a "0". I then want to reassemble the values, and...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.