View Full Version : Finding field separator in a text file
07-05-2005, 02:16 PM
I want to find the field separator in a text file. Normally our text files will have these , | \t field separators. How can i find it. Using Shell script or Perl script.
Regards / Thanks
Swaroop Kumar. Tata
List Management Team [ Ybrant Technologies ]
Mail: email@example.com | firstname.lastname@example.org
I don't understand the question. You want to find out what the field seperator is? That's what you seem to be saying, yet you later specify that the field seperator is | \t.
Whatever you're doing, a creative use of grep(1) and awk(1) should do the trick. See the manpages for more info.
07-08-2005, 12:13 PM
Hi Thanks for your reply. But what exactly i have asked is.
I have text file as input
I want to find the field separator in the text file.
Ususally the field separators will be , [ Comma ] or | [ Pipe ] or \t [ Tab ]
How can i do dis.
Ah, I see.
Well, it's very difficult to do this unless you already have some more info about the file (how many fields does it have per record? Does it use any possible field seperators in the data?)
If neither of these are consistent throughout your files, you'll be forced to just try them all until you get data that makes sense.
01-24-2007, 10:55 AM
Hi, I also have a similar problem.
I work for a company who use a pearl render program to generate WebPages.
They have a bespoke method of coding the web pages (an example of code can be found below)
The problem I have is the fields of the WebPages are outputted to software called Peregrine Service Centre. But when you have a complex form with a hundred or more fields, its impossible to keep a track of fields you may have missed in the template for service centre.
An Example of code is as follows:
This would output:
Work Location [CustomerWorkAddress]
(see attachment example.bmp)
Note.  is a input field in a form.
In the code above the first line creates The title of the field displayed on the form.
The second line indicates the field.
The | (Pipes) divide information for the attribute, there are always 6 ‘|’ to an attribute on the form acting as separators for the specification for the attribute.
In the first line:
‘-‘ Indicates a new line
‘180’ indicates the width of the attribute
‘label’ which implies the field type to be a label on the form.
‘Work Location’ that is the label to be displayed.
In the second line:
There is no – indicating no new line.
‘input’ indicating the type of field to be an input text box.
‘CustomerWorkAddress’ is the field name, which will contain the value of the input.
‘4’is the number of lines the input box covers
‘30’ is the field width.
Being quite new to programming, I need to identify all the field names and place them into a text file between ‘**’ (two stars). I.e. *CustomerWorkAddress*.
Can anyone think of a way to do this?
Thanks in advance. Saff
I would seriously suggest using a database instead. If you don't have access to a database server, you could try SQLite, which saves a database as a simple file. If it's necessary to have this format for your bespoke software, it shouldn't be too hard to reconstruct it from the database, after changes have been made.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.