473,511 Members | 16,730 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Creating database records from a Text File

4 New Member
I have a program that I download a text file that has multiple lines in the following style:

This is the title.

Verse 1
This is the first line
This is the second line

Verse 2
This is the first line
This is the second line

I can parse the text file to some degree but what I really need is to be able to read the first line and add a new record and then read the next line and know if the next line is Verse 1 or Verse 2 and then add the next lines to the record. I am not sure how to loop through correctly.

Thank you for your time and information.


Sincerely,

Keith Kelly
Sep 5 '07 #1
2 1140
VBPhilly
95 New Member
I have a program that I download a text file that has multiple lines in the following style:

This is the title.

Verse 1
This is the first line
This is the second line

Verse 2
This is the first line
This is the second line

I can parse the text file to some degree but what I really need is to be able to read the first line and add a new record and then read the next line and know if the next line is Verse 1 or Verse 2 and then add the next lines to the record. I am not sure how to loop through correctly.

Thank you for your time and information.


Sincerely,

Keith Kelly
Looks like you have a predictable format such as:

Verse1
Line1
Line2

You'll need to loop the file, as normal, and simply look for "Verse". This is your record begin flag.
Then, you use counting to get the rest of the data. Line1, Line2.

Then, do the same thing until EOF.

Ide help more if I had a data sample. Show us sample data.
Sep 5 '07 #2
ncag
4 New Member
Thanks for replying.

Here is the code that I am using. It is rough. Here is the actual text file lines.

I have a large text box that I first pasre the text file into to look at. Then I have a command button that actually parses the textbox.

command button code to parse the text file into the textbox

Dim nfilenum As Integer
Dim llinecount As Integer
Dim snextline As String
Dim stext As String

nfilenum = FreeFile
CommonDialog1.InitDir = "g:\vb projects\icasttest\songs\"
CommonDialog1.Filter = "*.txt"
CommonDialog1.ShowOpen
gPath = CommonDialog1.FileName

Open gPath For Input As nfilenum
' Read the contents of the file
Do While Not EOF(nfilenum)
Line Input #nfilenum, snextline
snextline = snextline & vbCrLf
stext = stext & snextline
Loop
Text1.Text = stext
close nfilenum


command button code to parse the textbox and create the database records

Dim pos As Integer
Dim entry() As String

entry = Split(Text1.Text, vbCrLf & vbCrLf)
pos = 0

Do While pos < UBound(entry)
If Trim$(entry(pos)) <> "" Then
database.addnew
database.recordset!field = trim$entry(pos))
End If
pos = pos + 1
Loop



The problem I can't get over is once I find the "Verse 1" header I do not know how to continue adding to the database until it gets to the next vbcrlf.

Here is the actual text file:

Here I Am To Worship


Verse 1
Light of the world
You stepped down into darkness
Opened my eyes let me see
Beauty that made
This heart adore You
Hope of a life spent with You


Chorus 1
So here I am to worship
Here I am to bow down
Here I am to say that You're my God
And You're altogether lovely
Altogether worthy
Altogether wonderful to me


Verse 2
King of all days
Oh so highly exalted
Glorious in heaven above
Humbly You came
To the earth You created
All for love's sake became poor


Misc 1
(BRIDGE)
And I'll never know how much it cost
To see my sin upon that cross
And I'll never know how much it cost
To see my sin upon that cross



Thank you very much.

Sincerely,

Keith Kelly
Sep 6 '07 #3

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

Similar topics

1
4430
by: Rakesh Patel | last post by:
Hi All, I want to load XML file data into database. There is seperate XML file for each record (2000 record) and I want to load these records into a single Oracle database table using...
31
3650
by: Neil | last post by:
I have an Access 2000 MDB with ODBC linked tables to a SQL Server 7 back end. I currently have a selections table in the front end file which the users use to make selections of records. The table...
1
498
by: Bridget Willey | last post by:
I am using ACT 6 and am trying to "split" the database between records for customers and junk records. The accounts designated as "customers" have that word in the ID field, and I am using that...
1
2898
by: longtim | last post by:
I have been having endless difficulty creating reports/queries that set any relevent parameters from controls in forms. I am creating an application under access 2003 but will target access...
2
6200
by: Todd_M | last post by:
I was wondering what anyone might suggest as "best practice" patterns for streaming out fixed formatted text files with C#? Let's say we get our data in a dataset table and we need to iterate over...
4
2394
by: RSH | last post by:
Hi, I have a situation where I have created a little application that makes an Access database from a SQL Database for reporting purposes. it does the job well, but it seems a bit slow. Is...
5
2683
by: Mark | last post by:
Hi I have an application (in vb.NET 2005) which holds data in SQL Server and some of the SQL records are simply paths to related files. I would like to be able to do a text search on both the...
7
11767
by: ianenis.tiryaki | last post by:
well i got this assignment which i dont even have a clue what i am supposed to do. it is about reading me data from the file and load them into a parallel array here is the question: Step (1) ...
8
1464
by: Ian | last post by:
I have an Access 2000 database that checks once every 4 seconds to see if a text file exists, if it does then it opens the text file, reads an ID, opens a report based on that ID, then deletes the...
4
2045
by: rn5a | last post by:
Assume that there's a website named www.abc.com. There are 2 ASPX files & one MS-Access database file in this site. The 1st ASPX file is named "SearchForm.aspx" & the 2nd ASPX file is named...
0
7355
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,...
1
7081
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5668
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5066
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
3225
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3213
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1576
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
781
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
447
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.