View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
GS[_2_] GS[_2_] is offline
external usenet poster
 
Posts: 3,514
Default Line Input is reading extra lines?

The structure of the text file will dictate what results you get! For
example, if you copy 2 paragraphs from a Word doc and paste them into a
text editor (or a worksheet), you end up with 3 lines (or rows in wks),
regardless of the number of sentences in each paragraph. A CrLf denotes
a new line. Usually, paragraphs are separated by a blank line, ergo the
3 lines in the copy/paste example. So in this case the paragraph
delimiter is a blank empty line. This complicates parsing the Word doc.

When text files are properly structured to store data, the 1st line
should contain fieldnames, the remaining lines are individual records,
and there should be no blank lines anywhere in the file.

If the Word doc above was structured to use paragraph spacing instead
of a blank CrLf, the doc would parse more eaily because the paragraph
separator will be a CrLf, same as the record separator in a properly
structured data file.

Go back to the Word doc an delete the empty line between the
paragraphs, and set spacing before to render the desired 'appearance'
of how the 2nd paragraph is spaced from the 1st. This structor would be
dictated by Styles defs in a document template so the content conforms
to some consistent standard. While positioning content via the space,
tab, and enter keys for simple printing is the general practice, people
get away with it because printing is a WYSIWYG process. Not the case
when converting that doc to other file formats suitable for ereader
devices because the rendered results are highly unpredictable. The
template structure I described earlier renders predictable results in
all output formats I've generated (11 to date). Note that output to a
PDF file is not so much a conversion as it is a WYSIWYG printout.

Probably more info here than needed, but importing text to a worksheet
can be a very confusing process to one who doesn't understand file
structure concepts!

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion