Converet plain text to table

G

geotso

I have a "table" in plain text like this:

1. [name] [surname] 0:36:27
2. [another name] [and surname] 0:46:27
3. [third name] [and surname] 1:03:42
4. [and so one...] 2:04:18

Where:
- After the order number there is an empty space
- Between [name] [surname] there is an empty space
- Between [surname] [time] there are empty spaces and/or tab characters.

Is there a simple way to convert it to a table (I don't know VBA)?
 
S

Suzanne S. Barnhill

I would start by using wildcards to replace any number of spaces with a tab,
then use Table | Convert | Table to Text, separating at tabs. If the Replace
operation results in multiple tabs between elements, replace those with a
single tab before converting.
 
T

Terry Farrell

Just to clarify Suzanne's advice...

After the replace, you will see the list looking like:

[1.] tab [name] tab [surname] tab [0:36:27] return

Then when you select the list and use convert Text to Table choosing the TAB
as the separator, you will have a four column table. If you need the empty
space afterwards, you simply select the column to the right and chose
Insert, Column to the Left (or vice versa).

BTW, if you are ever going to place the table in a spreadsheet, you should
consider changing your order numbering system because it may be confused as
the standard time format (hours:minutes:seconds): it certainly confused me
at first glance.

Terry
 
G

geotso

then, "Suzanne S. Barnhill" climbed to the rostrum and said:
I would start by using wildcards to replace any number of spaces with a tab,

And what is the expression for this, please?
I've tried " {2,}" (no quotes - starting empty space) and Word (2007) warns
me that the expression is not valid.
then use Table | Convert | Table to Text, separating at tabs. If the Replace
operation results in multiple tabs between elements, replace those with a
single tab before converting.
Once again, what is the expression for "multiple tabs"?
I've tried "^t{2,}" (no quotes) with the same as above results...

Thank you very much
 
S

Suzanne S. Barnhill

This works for me provided I remember to check the "Use wildcards" box.
 
J

Jay Freedman

then, "Suzanne S. Barnhill" climbed to the rostrum and said:

And what is the expression for this, please?
I've tried " {2,}" (no quotes - starting empty space) and Word (2007) warns
me that the expression is not valid.

That expression works in my copy of Word 2007, and it should work in yours. If
you can't make it work, then try surrounding the space character (but not the
{2,}) in square brackets:

[ ]{2,}

Also, in your initial post you mentioned that the name and time may be separated
by an assortment of spaces and tabs. You can replace the whole lot in one
wildcard search by using the expression

[ ^9]{2,}

That is, the space is still in the brackets, plus the numeric code for a tab
character (see http://www.gmayor.com/replace_using_wildcards.htm for a list of
codes).
Once again, what is the expression for "multiple tabs"?
I've tried "^t{2,}" (no quotes) with the same as above results...

Thank you very much

To search for multiple tabs, use an expression like the one above with the ^9
code, but leave out the space character. As explained in Graham's article, codes
such as ^t and ^p don't work in the Find What box of a wildcard search, only in
the Replace With box (and in both boxes for a non-wildcard search).
 
S

Suzanne S. Barnhill

I also tried [ ]{2,} and found it didn't work because I'd forgotten to check
"Use wildcards." When I did check it, the expression worked without the
brackets, and it's all too easy to get so wrapped up in figuring out the
right search term that you forget to check the box; I'm guessing that's the
OP did.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Jay Freedman said:
then, "Suzanne S. Barnhill" climbed to the rostrum and said:

And what is the expression for this, please?
I've tried " {2,}" (no quotes - starting empty space) and Word (2007)
warns
me that the expression is not valid.

That expression works in my copy of Word 2007, and it should work in
yours. If
you can't make it work, then try surrounding the space character (but not
the
{2,}) in square brackets:

[ ]{2,}

Also, in your initial post you mentioned that the name and time may be
separated
by an assortment of spaces and tabs. You can replace the whole lot in one
wildcard search by using the expression

[ ^9]{2,}

That is, the space is still in the brackets, plus the numeric code for a
tab
character (see http://www.gmayor.com/replace_using_wildcards.htm for a
list of
codes).
Once again, what is the expression for "multiple tabs"?
I've tried "^t{2,}" (no quotes) with the same as above results...

Thank you very much

To search for multiple tabs, use an expression like the one above with the
^9
code, but leave out the space character. As explained in Graham's article,
codes
such as ^t and ^p don't work in the Find What box of a wildcard search,
only in
the Replace With box (and in both boxes for a non-wildcard search).

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.
 
J

Jay Freedman

If you use a wildcard expression but forget to check the "Use wildcards" box, it
simply won't find anything. But if the box is checked and the expression isn't
correctly formed according to the wildcard rules, then you get a message box
saying that the search expression isn't valid. From geotso's post, I gathered
that he saw the message box.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.

I also tried [ ]{2,} and found it didn't work because I'd forgotten to check
"Use wildcards." When I did check it, the expression worked without the
brackets, and it's all too easy to get so wrapped up in figuring out the
right search term that you forget to check the box; I'm guessing that's the
OP did.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

Jay Freedman said:
then, "Suzanne S. Barnhill" climbed to the rostrum and said:
I would start by using wildcards to replace any number of spaces with a
tab,

And what is the expression for this, please?
I've tried " {2,}" (no quotes - starting empty space) and Word (2007)
warns
me that the expression is not valid.

That expression works in my copy of Word 2007, and it should work in
yours. If
you can't make it work, then try surrounding the space character (but not
the
{2,}) in square brackets:

[ ]{2,}

Also, in your initial post you mentioned that the name and time may be
separated
by an assortment of spaces and tabs. You can replace the whole lot in one
wildcard search by using the expression

[ ^9]{2,}

That is, the space is still in the brackets, plus the numeric code for a
tab
character (see http://www.gmayor.com/replace_using_wildcards.htm for a
list of
codes).
then use Table | Convert | Table to Text, separating at tabs. If the
Replace
operation results in multiple tabs between elements, replace those with
a
single tab before converting.

Once again, what is the expression for "multiple tabs"?
I've tried "^t{2,}" (no quotes) with the same as above results...

Thank you very much

To search for multiple tabs, use an expression like the one above with the
^9
code, but leave out the space character. As explained in Graham's article,
codes
such as ^t and ^p don't work in the Find What box of a wildcard search,
only in
the Replace With box (and in both boxes for a non-wildcard search).

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup
so all may benefit.
 
G

geotso

That expression works in my copy of Word 2007, and it should work in yours. If
you can't make it work, then try surrounding the space character (but not the
{2,}) in square brackets:

[ ]{2,}

It definitely doesn't work :(

I've tried both suggestions, to no avail...
I've also turned on the "Show all formatting marks" just in case I was wrong
about the empty spaces, and they was really there! I counted 13 dot marks
just between the first surname and his time.

I've also tried the ^s character (non-breaking space), just to receive the
same disappointing error message :(
 
S

Suzanne S. Barnhill

How very odd! Failing wild cards, you can always just search for two spaces
repeatedly until Find returns no results.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

geotso said:
That expression works in my copy of Word 2007, and it should work in
yours. If
you can't make it work, then try surrounding the space character (but not
the
{2,}) in square brackets:

[ ]{2,}

It definitely doesn't work :(

I've tried both suggestions, to no avail...
I've also turned on the "Show all formatting marks" just in case I was
wrong about the empty spaces, and they was really there! I counted 13 dot
marks just between the first surname and his time.

I've also tried the ^s character (non-breaking space), just to receive the
same disappointing error message :(
 
G

geotso

then, "Jay Freedman" climbed to the rostrum and said:
If you use a wildcard expression but forget to check the "Use wildcards" box, it
simply won't find anything. But if the box is checked and the expression isn't
correctly formed according to the wildcard rules, then you get a message box
saying that the search expression isn't valid. From geotso's post, I gathered
that he saw the message box.
I do see the message box, as you said, and I'm pretty sure I check the "use
wildcards" checkbox!
 
G

geotso

then, "Suzanne S. Barnhill" climbed to the rostrum and said:
How very odd! Failing wild cards, you can always just search for two spaces
repeatedly until Find returns no results.

As I said, I've counted 13 empty spaces just in the first row of the list.
Given that the list consists of 364 rows, could you please tell me how many
"two spaces repeatedly" should I found to complete the search? :)

Furthermore, the problem isn't just the amount of time I'll need for the
specific task. The problem is why the wildcards don't work for me, while
they do work for Jay and Suzanne?
 
S

Suzanne S. Barnhill

I would actually start by searching for 13 spaces. When all these have been
converted to tabs, search for 12 spaces, and so on. This should require only
a dozen passes.
 
G

geotso

then, "Suzanne S. Barnhill" climbed to the rostrum and said:
I would actually start by searching for 13 spaces. When all these have been
converted to tabs, search for 12 spaces, and so on. This should require only
a dozen passes.

even so, WILDCARDS DON'T WORK...

(Sorry for I'm yelling, but I'm really mad right now!)


Following your suggestion I made these replacements:

Replace all spaces/tabs occurrences with the string "zzz" (no quotes).
So, I finally end up with something like this:

1. [name] [surname]zzzzzzzzzzzz[time]
2. [other name] [other surname]zzz[time]
3. [and so on]zzzzzzzzzzzzzzzzzz[time]

Then, I tried to replace z{3,} with ^t (and yes, the "use wildcards" was
checked*)...
Guess what?
The same ugly "invalid expression" message box!

The solution:
- Give up (or should I say through away?) Word and use UltraEdit Text Editor
instead!
 
G

geotso

- Give up (or should I say through away?)

ooops! it should be throw away!
Awful english - awful mood!
 
S

Suzanne S. Barnhill

No, for the search I'm describing, you don't need wildcards. Just search
(without wildcards) for 13 spaces and replace with a tab. Then search for 12
spaces and replace with a tab. Alternatively, if there are no spaces within
the names you want in separate cells, you can just search for ^w (white
space) and replace with ^t.

--
Suzanne S. Barnhill
Microsoft MVP (Word)
Words into Type
Fairhope, Alabama USA

geotso said:
then, "Suzanne S. Barnhill" climbed to the rostrum and said:
I would actually start by searching for 13 spaces. When all these have
been
converted to tabs, search for 12 spaces, and so on. This should require
only
a dozen passes.

even so, WILDCARDS DON'T WORK...

(Sorry for I'm yelling, but I'm really mad right now!)


Following your suggestion I made these replacements:

Replace all spaces/tabs occurrences with the string "zzz" (no quotes).
So, I finally end up with something like this:

1. [name] [surname]zzzzzzzzzzzz[time]
2. [other name] [other surname]zzz[time]
3. [and so on]zzzzzzzzzzzzzzzzzz[time]

Then, I tried to replace z{3,} with ^t (and yes, the "use wildcards" was
checked*)...
Guess what?
The same ugly "invalid expression" message box!

The solution:
- Give up (or should I say through away?) Word and use UltraEdit Text
Editor instead!
 
G

Graham Mayor

Send me a sample of the document to the link on my web site so that I can
check that we are all singing from the same hymn sheet, however in the
meantime try a search for

([0-9]{1,}.)[ ]{1,}([A-Za-z]{1,})[ ]{1,}([A-Za-z]{1,})[ ^0160^t]{1,}([0-9])
replace with
\1^t\2^t\3^t\4

with the wildcard option set.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

geotso

then, "Graham Mayor" climbed to the rostrum and said:
Send me a sample of the document to the link on my web site so that I can

you (and everyone) can get it from here: http://geotso.com/sample.aspx
check that we are all singing from the same hymn sheet, however in the
meantime try a search for

([0-9]{1,}.)[ ]{1,}([A-Za-z]{1,})[ ]{1,}([A-Za-z]{1,})[ ^0160^t]{1,}([0-9])
replace with
\1^t\2^t\3^t\4

with the wildcard option set.
The same "invalid expression" message box :(
 

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