473,385 Members | 1,958 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.

Problem with putting up conditionals for splitting a text file

Hi Guys,

I am working to achieve something that lokks really simple , but it actually sint.
I have I text tab delimited file. in every line of that file at the same position in every row of the file I will have a bit that I would want to compare against 23 values (I will call them criteria). So if on every row the string I need matches one of tjhese values then that row will be written in File1.Txt if that value doesn`t match any of the criteria the whole row will be sent to File2.txt.
So far managed to get the original file written in the same format in a newly created file.
I have an idea of how to get the functionality I described working but am stuck with correct syntax.
Here is what I have so far:
Expand|Select|Wrap|Line Numbers
  1.  Dim fs As New FileStream("C:\Original.txt", FileMode.Open, FileAccess.Read)
  2.  
  3.  
  4.         RichTextBox1.Text = ""
  5.         Dim d As New StreamReader(fs)
  6.  
  7.         d.BaseStream.Seek(0, SeekOrigin.Begin)
  8.  
  9.         While d.Peek() > -1
  10.             Dim s As String = d.ReadLine()
  11.  
  12.             If s.Length > 1000 Then
  13.  
  14.  
  15.                 s = s.Remove(1000)
  16.  
  17.             End If
  18.  
  19.  
  20.  
  21.  
  22.             RichTextBox1.Text &= s & Environment.NewLine
  23.  
  24.  
  25.         End While
  26.  
  27.  
  28.  
  29.         d.Close()
  30.  
  31.         Dim fs1 As New FileStream("C:\File1.txt", FileMode.Create, FileAccess.Write)
  32.         Dim ss As New StreamWriter(fs1)
  33.         ss.WriteLine(RichTextBox1.Text)
  34.         ss.Close()
  35.  
  36.  
  37.  
  38.  
  39.   End Sub
  40.  
Now I will need to declare every single row in RichTextBox1 as String then will have to get the bit I need will have to declare that as well(I will need from every row the string taht is between characters 96 and 104), also where do I keep the 23 criteraia values.
I am lost totaly , I have no idea how would that look like.
If someone can help here would be great
Thank you
Apr 27 '09 #1
1 966
iam_clint
1,208 Expert 1GB
Well you need to start at the beginning
1. Load the file
2. Split by tab
3. Loop each value and put it against some criteria
4. Write row to new text file


for step 3 I would try and use regular expressions http://www.regular-expressions.info/
Apr 29 '09 #2

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

Similar topics

14
by: Luka Milkovic | last post by:
Hello, I have a little problem and although it's little it's extremely difficult for me to describe it, but I'll try. I have written a program which extracts certain portions of my received...
4
by: Hans Almåsbakk | last post by:
Hi, I have a problem which I believe is seen before: Finding the correct pattern to use, in order to split a line correctly, using the split function in the re module. I'm new to regexp, and...
13
by: nobody | last post by:
Hello all, I've searched just about everything and although I can see that other people are having problems, but theirs don't seem to relate, so in a last ditch attempt, my posting! Script...
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...
1
by: Andy Britcliffe | last post by:
Hi I'm faced with the situation where I could have a single physical file that could contain multiplie XML documents e.g file.txt contains the following: <?xml version="1.0"...
3
by: Bjorn | last post by:
Hi,. i try to change the color of the main menu when the visitor of the site is logged. When not logged, it must be red, when logged, it must be green. I start in the Master¨Page with putting...
3
omerbutt
by: omerbutt | last post by:
hi there i have downloaded a prototype tooltip from http://www.nickstakenburg.com/projects/prototip/ the logic it uses is to call the script after creating the <div> for example i am using the...
9
by: Salad | last post by:
I have access, for testing at my client's site, a Win2000 computer running A2003 retail. He recently upgraded all of his other machines to DualCore Pentiums with 2 gig ram and run A2003 runtime. ...
1
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: 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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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.