PC Review


Reply
Thread Tools Rate Thread

concatenating Line Input

 
 
LMC
Guest
Posts: n/a
 
      1st Oct 2009
Using the Line Input method I am reading a CSV text file that originated from
a table with paragraph returns within single cells. The CSV format places the
embedded paragraphs on seperate lines and I am trying to reconcatenate the
embedded returns while importing the content into Access 2003. I get stuck
with the nested loop and If-Then-Else logic when attempting to get the code
to concatenate the last line between quotes.

A simplified CSV example looks similar to this where rows 3 thru 5 would be
concatenated into row 2 which would become "f" "g" "h" & "i" in the third
field with paragraphs returns between each letter.
1, "a", "b", "c"
2, "d", "e", "f
3, g
4, h
5, i"
6, "x", "y", "z"


Here's the code in it's current state...
Dim strRow as String, intF as Integer, strLine as String
'code deleted for brevity that opens the text file and reads column names
strRow = ""
Do While EOF(intF) = False
Line Input #intF, strLine
If Not Right (strLine, 1) = char(34) Then
strRow = strRow & strLine & Char(13)
Loop
Else
strRow = strLine
End If
'code deleted for brevity that splits strRow and writes into field
values
strRow = ""
Loop

I'd appreciate any help in modifying the code to perform my need.
LMC
 
Reply With Quote
 
 
 
 
Ken Snell
Guest
Posts: n/a
 
      2nd Oct 2009
Try this modified code structure:

Dim strRow as String, intF as Integer, strLine as String
Dim blnFullLine As Boolean
'code deleted for brevity that opens the text file and reads column
names
strRow = ""
blnFullLine = False
blnBuilding = False
Do While EOF(intF) = False
Line Input #intF, strLine
If Right (strLine, 1) = char(34) Then
strRow = strRow & strLine & Char(13)
blnFullLine = True
Else
strRow = strRow & strLine
blnFullLine = False
End If
If blnFullLine = True Then
'code deleted for brevity that splits strRow and writes into field
values
strRow = ""
End If
Loop


--

Ken Snell
http://www.accessmvp.com/KDSnell/


"LMC" <(E-Mail Removed)> wrote in message
news:229E36E0-6B00-421B-B932-(E-Mail Removed)...
> Using the Line Input method I am reading a CSV text file that originated
> from
> a table with paragraph returns within single cells. The CSV format places
> the
> embedded paragraphs on seperate lines and I am trying to reconcatenate the
> embedded returns while importing the content into Access 2003. I get stuck
> with the nested loop and If-Then-Else logic when attempting to get the
> code
> to concatenate the last line between quotes.
>
> A simplified CSV example looks similar to this where rows 3 thru 5 would
> be
> concatenated into row 2 which would become "f" "g" "h" & "i" in the third
> field with paragraphs returns between each letter.
> 1, "a", "b", "c"
> 2, "d", "e", "f
> 3, g
> 4, h
> 5, i"
> 6, "x", "y", "z"
>
>
> Here's the code in it's current state...
> Dim strRow as String, intF as Integer, strLine as String
> 'code deleted for brevity that opens the text file and reads column
> names
> strRow = ""
> Do While EOF(intF) = False
> Line Input #intF, strLine
> If Not Right (strLine, 1) = char(34) Then
> strRow = strRow & strLine & Char(13)
> Loop
> Else
> strRow = strLine
> End If
> 'code deleted for brevity that splits strRow and writes into field
> values
> strRow = ""
> Loop
>
> I'd appreciate any help in modifying the code to perform my need.
> LMC



 
Reply With Quote
 
LMC
Guest
Posts: n/a
 
      2nd Oct 2009
Ken, your suggestion of adding the boolean variable did the trick; although I
had to swap the placement of the two strRow statements for it to work. Many
thanks; I had spent all day trying to figure that out on my own and wasn't
getting it.

> Dim strRow as String, intF as Integer, strLine as String
> Dim blnFullLine As Boolean
> 'code deleted for brevity opens the text file and reads column names
> strRow = ""
> blnFullLine = False
> blnBuilding = False
> Do While EOF(intF) = False
> Line Input #intF, strLine
> If Right (strLine, 1) = char(34) Then
>> strRow = strRow & strLine

> blnFullLine = True
> Else
>> strRow = strRow & strLine & Char(13)

> blnFullLine = True
> End If
> If blnFullLine = True Then
> 'code deleted for brevity that splits strRow and writes into field
> values
> strRow = ""
> End If
> Loop



"Ken Snell" wrote:

> Try this modified code structure:
>
> Dim strRow as String, intF as Integer, strLine as String
> Dim blnFullLine As Boolean
> 'code deleted for brevity that opens the text file and reads column
> names
> strRow = ""
> blnFullLine = False
> blnBuilding = False
> Do While EOF(intF) = False
> Line Input #intF, strLine
> If Right (strLine, 1) = char(34) Then
> strRow = strRow & strLine & Char(13)
> blnFullLine = True
> Else
> strRow = strRow & strLine
> blnFullLine = False
> End If
> If blnFullLine = True Then
> 'code deleted for brevity that splits strRow and writes into field
> values
> strRow = ""
> End If
> Loop
>
>
> --
>
> Ken Snell
> http://www.accessmvp.com/KDSnell/
>
>
> "LMC" <(E-Mail Removed)> wrote in message
> news:229E36E0-6B00-421B-B932-(E-Mail Removed)...
> > Using the Line Input method I am reading a CSV text file that originated
> > from
> > a table with paragraph returns within single cells. The CSV format places
> > the
> > embedded paragraphs on seperate lines and I am trying to reconcatenate the
> > embedded returns while importing the content into Access 2003. I get stuck
> > with the nested loop and If-Then-Else logic when attempting to get the
> > code
> > to concatenate the last line between quotes.
> >
> > A simplified CSV example looks similar to this where rows 3 thru 5 would
> > be
> > concatenated into row 2 which would become "f" "g" "h" & "i" in the third
> > field with paragraphs returns between each letter.
> > 1, "a", "b", "c"
> > 2, "d", "e", "f
> > 3, g
> > 4, h
> > 5, i"
> > 6, "x", "y", "z"
> >
> >
> > Here's the code in it's current state...
> > Dim strRow as String, intF as Integer, strLine as String
> > 'code deleted for brevity that opens the text file and reads column
> > names
> > strRow = ""
> > Do While EOF(intF) = False
> > Line Input #intF, strLine
> > If Not Right (strLine, 1) = char(34) Then
> > strRow = strRow & strLine & Char(13)
> > Loop
> > Else
> > strRow = strLine
> > End If
> > 'code deleted for brevity that splits strRow and writes into field
> > values
> > strRow = ""
> > Loop
> >
> > I'd appreciate any help in modifying the code to perform my need.
> > LMC

>
>
>

 
Reply With Quote
 
Ken Snell
Guest
Posts: n/a
 
      2nd Oct 2009
Sorry about the misplacement of the strRow lines, but glad you figured it
out.

--

Ken Snell
http://www.accessmvp.com/KDSnell/


"LMC" <(E-Mail Removed)> wrote in message
news:B034F71E-3DDB-48FD-B469-(E-Mail Removed)...
> Ken, your suggestion of adding the boolean variable did the trick;
> although I
> had to swap the placement of the two strRow statements for it to work.
> Many
> thanks; I had spent all day trying to figure that out on my own and wasn't
> getting it.
>
>> Dim strRow as String, intF as Integer, strLine as String
>> Dim blnFullLine As Boolean
>> 'code deleted for brevity opens the text file and reads column names
>> strRow = ""
>> blnFullLine = False
>> blnBuilding = False
>> Do While EOF(intF) = False
>> Line Input #intF, strLine
>> If Right (strLine, 1) = char(34) Then
>>> strRow = strRow & strLine

>> blnFullLine = True
>> Else
>>> strRow = strRow & strLine & Char(13)

>> blnFullLine = True
>> End If
>> If blnFullLine = True Then
>> 'code deleted for brevity that splits strRow and writes into
>> field
>> values
>> strRow = ""
>> End If
>> Loop

>
>
> "Ken Snell" wrote:
>
>> Try this modified code structure:
>>
>> Dim strRow as String, intF as Integer, strLine as String
>> Dim blnFullLine As Boolean
>> 'code deleted for brevity that opens the text file and reads column
>> names
>> strRow = ""
>> blnFullLine = False
>> blnBuilding = False
>> Do While EOF(intF) = False
>> Line Input #intF, strLine
>> If Right (strLine, 1) = char(34) Then
>> strRow = strRow & strLine & Char(13)
>> blnFullLine = True
>> Else
>> strRow = strRow & strLine
>> blnFullLine = False
>> End If
>> If blnFullLine = True Then
>> 'code deleted for brevity that splits strRow and writes into
>> field
>> values
>> strRow = ""
>> End If
>> Loop
>>
>>
>> --
>>
>> Ken Snell
>> http://www.accessmvp.com/KDSnell/
>>
>>
>> "LMC" <(E-Mail Removed)> wrote in message
>> news:229E36E0-6B00-421B-B932-(E-Mail Removed)...
>> > Using the Line Input method I am reading a CSV text file that
>> > originated
>> > from
>> > a table with paragraph returns within single cells. The CSV format
>> > places
>> > the
>> > embedded paragraphs on seperate lines and I am trying to reconcatenate
>> > the
>> > embedded returns while importing the content into Access 2003. I get
>> > stuck
>> > with the nested loop and If-Then-Else logic when attempting to get the
>> > code
>> > to concatenate the last line between quotes.
>> >
>> > A simplified CSV example looks similar to this where rows 3 thru 5
>> > would
>> > be
>> > concatenated into row 2 which would become "f" "g" "h" & "i" in the
>> > third
>> > field with paragraphs returns between each letter.
>> > 1, "a", "b", "c"
>> > 2, "d", "e", "f
>> > 3, g
>> > 4, h
>> > 5, i"
>> > 6, "x", "y", "z"
>> >
>> >
>> > Here's the code in it's current state...
>> > Dim strRow as String, intF as Integer, strLine as String
>> > 'code deleted for brevity that opens the text file and reads column
>> > names
>> > strRow = ""
>> > Do While EOF(intF) = False
>> > Line Input #intF, strLine
>> > If Not Right (strLine, 1) = char(34) Then
>> > strRow = strRow & strLine & Char(13)
>> > Loop
>> > Else
>> > strRow = strLine
>> > End If
>> > 'code deleted for brevity that splits strRow and writes into
>> > field
>> > values
>> > strRow = ""
>> > Loop
>> >
>> > I'd appreciate any help in modifying the code to perform my need.
>> > LMC

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I start new line when concatenating text strings in excel? =?Utf-8?B?TWF4?= Microsoft Excel Misc 2 26th Jan 2006 05:48 PM
concatenating line decided not to work =?Utf-8?B?UGFwYSBKb25haA==?= Microsoft Excel Programming 3 18th Mar 2005 01:57 PM
Reads entire *.txt file into string opposed to a desired line by line input. ej_user Microsoft Excel Programming 3 11th Oct 2004 07:15 PM
Wild Card Concatenating with User Input Roy Microsoft Access ADP SQL Server 1 27th Feb 2004 05:46 AM
Concatenating data on a new line(within the same cell) RJ Microsoft Excel Worksheet Functions 2 1st Aug 2003 05:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:22 AM.