Import text with line breaks

W

Wladdy

Hi,

I have a Word document with a few hundred short stories.
Each story is under 10000 characters, and is made of paragraphs (ie:
groups of sentences ending by a paragrah sign ^p).
The first paragraph of each story is an integer which is the unique ID#
of that story.

I need to import the stories into an Access 2003 table with two fields:
[StoryID#] - an integer field
[StoryText] - a memo field

Now, how can I accomplish this and keep in [StoryText] the paragraph
structure of each story (ie: how do I import the text with line
breaks?).

I tried to reformat my Word file so that each [StoryID#] is followed by
a 'Tab', each paragraph except the last one of the story is followed by
'Line break', the last paragraph of the story is followed by
'Paragraph'. However, when I save into a txt file I lose all the line
breaks.

I tried another approach and replaced in the Word documents all the
line breaks with a unique string of characters (such as ****). I then
can save the txt file and successfullyt import it into Access. However,
I then cannot replace all the **** by line breaks in the [StoryText]
memo field.

Any guidance would be much appreciated.

W.
 
J

John Nurick

Hi Wladdy,

Try this, working with a copy of your document in Word.

1) Double up any quote marks in the stories. I.e. replace all
"
with
""

2) Still in Replace, click More, and then select Use Wildcards.

3) You want to replace the paragraph marks surrounding the integers with
quote marks and commas. So replace
^013([0-9]@)^013
with
"^p\1,"
(the parentheses in the search expression capture the integer, and the \1 in
the replacement expression puts it back).

3) Make similar changes manually to the beginning of the file, which should
change from
1
Once upon a time....
to
1,"Once upon a time...
and to the end, where you need to add a " and delete any blank lines.

4) Save the file as plain text. If you got the quote marks right, Access
will have no problem importing it as a comma-delimited file. Each paragraph
will end with the CRLF combination Access wants.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top