Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Best way to delimit text file

What is the best structure for delimiting text (.txt) files in
preparation for importation to an Excel workbook ?

An example might be:

Groups of Trees that have a heigth and width

Tree1;20;50;Tree2;30;47.8;Tree3.........

Would this be an acceptable way or is there another standard ?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Best way to delimit text file


If you can import it into Excel, you can save it with a
FileFormat:=xlText. My code looks like this:

FDATE = Format(Now, "YYYYMMDD")
fName = Worksheets("Nav").Range("A8") + FDATE + ".txt"
UF = "T:\Estimator\" + fName

Worksheets("Inputs").Activate
ActiveSheet.Select
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=UF, FileFormat:=xlText


Then when I open it with Excel as a text file, it puts everything in
the proper rows and columns.

I'm sure some of the more experienced users can come up with something
better.


--
Bruce001
------------------------------------------------------------------------
Bruce001's Profile: http://www.excelforum.com/member.php...o&userid=26630
View this thread: http://www.excelforum.com/showthread...hreadid=507866

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Best way to delimit text file


Bruce001 wrote:
If you can import it into Excel, you can save it with a
FileFormat:=xlText. My code looks like this:

FDATE = Format(Now, "YYYYMMDD")
fName = Worksheets("Nav").Range("A8") + FDATE + ".txt"
UF = "T:\Estimator\" + fName

Worksheets("Inputs").Activate
ActiveSheet.Select
ActiveSheet.Copy
ActiveWorkbook.SaveAs Filename:=UF, FileFormat:=xlText


I'm new to this, so I don't know what this code is or what it means.
Could someone maybe point me to a good "getting started" point for this
topic ? Much appreciated !!!

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 703
Default Best way to delimit text file

The semicolon is fine but can you create your text file with groups of
related data on individual lines? That would work great.

Tree1;20;50
Tree2;30;47.8
Tree3;etc.


"ern" wrote:

What is the best structure for delimiting text (.txt) files in
preparation for importation to an Excel workbook ?

An example might be:

Groups of Trees that have a heigth and width

Tree1;20;50;Tree2;30;47.8;Tree3.........

Would this be an acceptable way or is there another standard ?


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Best way to delimit text file

I have a simple standard. Tab Delimited with a Header row. (the header row
solves issues when importing into Access.)

I deviate from this only when the user insists upon another format and only
when they convince me that I can't convince them.

To manually create a tab delimited file:
File | Save As
Then select "Text (Tab delimited) (*.txt)" as the "Files of type" option.



--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"ern" wrote in message
oups.com...
What is the best structure for delimiting text (.txt) files in
preparation for importation to an Excel workbook ?

An example might be:

Groups of Trees that have a heigth and width

Tree1;20;50;Tree2;30;47.8;Tree3.........

Would this be an acceptable way or is there another standard ?





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Best way to delimit text file


AnExpertNovice wrote:
I have a simple standard. Tab Delimited with a Header row. (the header row
solves issues when importing into Access.)

I deviate from this only when the user insists upon another format and only
when they convince me that I can't convince them.

To manually create a tab delimited file:
File | Save As
Then select "Text (Tab delimited) (*.txt)" as the "Files of type" option.


Awesome. Thanks. Is it too much to ask to show a few lines of what a
tab-delimited text file would look like ? I will be writing to this
text file from a program, so I won't be able to manually create the
file as you suggested. I could however insert a '\t' between Excel
entries in the text file. thanks again.

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,327
Default Best way to delimit text file

"ern" skrev i melding
oups.com...

To manually create a tab delimited file:
File | Save As
Then select "Text (Tab delimited) (*.txt)" as the "Files of type"

option.

Awesome. Thanks. Is it too much to ask to show a few lines of what a
tab-delimited text file would look like ? I will be writing to this
text file from a program, so I won't be able to manually create the
file as you suggested.


I can't watch this any longer. Yes, it's far too much to ask. Chew your own
food. Do as described once, open the file in notepad or similar and have a
long good look at what a tab-delimited text file would look like.

Best wishes Harald


  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Best way to delimit text file


Harald Staff wrote:
"ern" skrev i melding
oups.com...

To manually create a tab delimited file:
File | Save As
Then select "Text (Tab delimited) (*.txt)" as the "Files of type"

option.

Awesome. Thanks. Is it too much to ask to show a few lines of what a
tab-delimited text file would look like ? I will be writing to this
text file from a program, so I won't be able to manually create the
file as you suggested.


I can't watch this any longer. Yes, it's far too much to ask. Chew your own
food. Do as described once, open the file in notepad or similar and have a
long good look at what a tab-delimited text file would look like.

Best wishes Harald


thank you very much harald : P you
would be proud of me i chewed my
own bagel this morning

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 36
Default Best way to delimit text file

I would try an experiment so you can see for yourself benefits and draw
backs.

Create an Excel workbook and copy the following text into the stated cells.
I would not copy the "A1:" portion of each line.

A1: Col 1
A2: This isn't a lot of fun, but it needs to be done.
A3: 1
A4: 4

B1: Col 2
B2: 2
B3: Plus, a famous quote says; "Seeing is Believing"
B4: 4

You end up with 2 columns and 4 rows with a header. You also have a mix of
text and numbers.

Now, do a File | Save As and save to the following files and the following
formats.
File ............ Type
Tab.txt....... Text (Tab delimited)
Csv.csv...... CSV (Comma delimited)
Csv.txt...... CSV (Comma delimited) (alternatively rename the csv.csv file
to csv.txt)
and any other formats you want to try.

Open each with notepad to see what they look like. With the CSV. notice all
the extra double quotes used. This doesn't look pretty if you now want to
print the file from the text file. Without the extra quotes the file would
not be imported into Excel, Access, etc. properly.

Open each with Excel. The .csv tells Excel what to use as a delimiter and
so it works nicely. However, try opening csv.txt with Excel and it doesn't
even give you a chance to parse the data. You get the extra quotes. Now,
try to parse it manually. Good luck!

What I have found in my limited experience is that Tab Separated is a more
universally accepted method of creating delimited files. Albeit by a very
slim margin. One application only accepts Tab Separated. (Which I think is
a weakness of the application, per a TIMTOWTDI ideology.)


--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"ern" wrote in message
oups.com...

AnExpertNovice wrote:
I have a simple standard. Tab Delimited with a Header row. (the header

row
solves issues when importing into Access.)

I deviate from this only when the user insists upon another format and

only
when they convince me that I can't convince them.

To manually create a tab delimited file:
File | Save As
Then select "Text (Tab delimited) (*.txt)" as the "Files of type"

option.

Awesome. Thanks. Is it too much to ask to show a few lines of what a
tab-delimited text file would look like ? I will be writing to this
text file from a program, so I won't be able to manually create the
file as you suggested. I could however insert a '\t' between Excel
entries in the text file. thanks again.



  #10   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Best way to delimit text file

However, try opening csv.txt with Excel and it doesn't
even give you a chance to parse the data.


There should be no difference in the way csv.txt and tab.txt are handled.
Both should take you through the Text Import Wizard. I have never
experienced what you are describing.

If you do get eveything in one column, then you can use Data=Text to
Columns

--
Regards,
Tom Ogilvy


"AnExpertNovice" wrote in message
...
I would try an experiment so you can see for yourself benefits and draw
backs.

Create an Excel workbook and copy the following text into the stated

cells.
I would not copy the "A1:" portion of each line.

A1: Col 1
A2: This isn't a lot of fun, but it needs to be done.
A3: 1
A4: 4

B1: Col 2
B2: 2
B3: Plus, a famous quote says; "Seeing is Believing"
B4: 4

You end up with 2 columns and 4 rows with a header. You also have a mix

of
text and numbers.

Now, do a File | Save As and save to the following files and the

following
formats.
File ............ Type
Tab.txt....... Text (Tab delimited)
Csv.csv...... CSV (Comma delimited)
Csv.txt...... CSV (Comma delimited) (alternatively rename the csv.csv

file
to csv.txt)
and any other formats you want to try.

Open each with notepad to see what they look like. With the CSV. notice

all
the extra double quotes used. This doesn't look pretty if you now want to
print the file from the text file. Without the extra quotes the file

would
not be imported into Excel, Access, etc. properly.

Open each with Excel. The .csv tells Excel what to use as a delimiter and
so it works nicely. However, try opening csv.txt with Excel and it

doesn't
even give you a chance to parse the data. You get the extra quotes. Now,
try to parse it manually. Good luck!

What I have found in my limited experience is that Tab Separated is a more
universally accepted method of creating delimited files. Albeit by a very
slim margin. One application only accepts Tab Separated. (Which I think

is
a weakness of the application, per a TIMTOWTDI ideology.)


--
My handle should tell you enough about me. I am not an MVP, expert, guru,
etc. but I do like to help.


"ern" wrote in message
oups.com...

AnExpertNovice wrote:
I have a simple standard. Tab Delimited with a Header row. (the

header
row
solves issues when importing into Access.)

I deviate from this only when the user insists upon another format and

only
when they convince me that I can't convince them.

To manually create a tab delimited file:
File | Save As
Then select "Text (Tab delimited) (*.txt)" as the "Files of type"

option.

Awesome. Thanks. Is it too much to ask to show a few lines of what a
tab-delimited text file would look like ? I will be writing to this
text file from a program, so I won't be able to manually create the
file as you suggested. I could however insert a '\t' between Excel
entries in the text file. thanks again.







Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Delimit using a formula 2 laandmc Excel Discussion (Misc queries) 3 March 5th 10 08:46 AM
delimit using a formula laandmc Excel Discussion (Misc queries) 2 March 4th 10 09:26 PM
Import text file - how to delimit (noob) ern[_2_] Excel Programming 3 February 2nd 06 08:19 PM
How to transpose an excel worksheet having more than 10000 rows into a text file, may by tab delimit Fred zheng Excel Programming 4 October 12th 05 06:07 PM
Why is delimit failing me _now_??? Patti[_3_] Excel Programming 2 April 3rd 04 07:04 PM


All times are GMT +1. The time now is 03:46 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"