How do I put spaces into a text string?

January 14, 2011 at 13:31:17
Specs: Windows XP, quad2.4ghz/2gb
Hello guys,

I have been browsing the net non-stop trying to find a solution to my problem and have lost myself. I have a price file from a vendor of mine that supplied it as .txt file. This file has text strings of probably 60,000 lines of data each line relating to the particular part. I need to be able to insert spaces or tabs at character intervals so that my inventory system can read the data. (Can provide character explanation if needed)

Vendor Notes: Parts Data is in text files, ASCII format with fixed record lengths of 63 bytes and a carriage return and line feed at end of each record.
If a part number has an interchange, the field “Part Name” will have the interchange part number as the description.

Inventory Notes: "Data to be imported must be either tab or comma delimited and in the following structure: 1-part number, 2-description, 3-cost, 4-list price"

Example from text file(vendor):

12000-22111 SCREW,TAPET 00002290000000000038100011A

Requested Result(Inventory Manager):

12000-22111 SCREW, TAPET 2.29 3.81
------------------------------------------------------------------------------
Parts number | Description | Dealer Cost | List Cost

If I am correct.

I am so lost and have tried to use SED's and got lost and even tried to create a .bat file. I am willing to try anything to get this working but have no where to start or to turn to. Any help would be GREAT.

I look forward to your helpful answers. Thank you so much.


See More: How do I put spaces into a text string?

Report •

#1
January 14, 2011 at 13:39:48

How do you parse this string:

00002290000000000038100011A

Can you assume that the first 7 digits are the Dealer Cost without the decimal

0000229

and the next 14 characters are the List Cost without the decimal.

00000000000381


Report •

#2
January 14, 2011 at 14:05:03
I look forward to your helpful answers.
Here's a possibly helpful question: What backwater import utility are you using that doesn't allow the importing of positional data?

How To Ask Questions The Smart Way


Report •

#3
January 20, 2011 at 12:16:25
In response to nails:

Part Number (key) location 1 to 15 Size:15
Interchange flag location 6 Size 1
Part Name location 17 Size 15
interchange code location 32 Size 1
Dealer Net-1 location 33 Size 7 Decimal 2
Dealer Net-2 location 40 Size 7 Decimal 2 No not use
Retail Price Location 47 Size 7 Decimal 2

Etc. i can upload a PDF explaining data and location if needed.

(( Parts Data is in text files, ASCII format with fixed record lengths of 63 bytes and a carriage return and line feed at end of each record.
If a part number has an interchange, the field “Part Name” will have the interchange part number as the description.))

Thank you. You can email me directly too if you would like to g.pimpin (at) ymail dot com

-gMon

In response to Razor 2.3:

I am not sure exactly. I think is uses SQL or OMNI PRO and has extension df1/df3 etc. it is an older DOS based program. My other vendors supply the data in these formats and it works good. (.dbf,.pbp and .mdb). The inventory program that they my customer uses is call STAR Service Manager BY integramanagement.

Any help would be great.

Thank you


Report •

Related Solutions

#4
January 20, 2011 at 14:18:48
Do you have access to awk? Here is my first take at it:

awk ' {
partnum=substr($0,1,12)
desc=substr($0,13,11)
dealer=substr($0,25,7)
list=substr($0,32,14)

printf("%s %s %.2f %.2f\n", partnum, desc, dealer/100, list/100)

}' datafile.txt


Your data example doesn't agree with the description you provided i.e. the example is only 52 characters long. I used your example data so you can easily change the substr functions to suit your own needs.

Here is how awk's substr is defined:

 substr(s, m, n)
           returns the n-character substring of s that begins  at
           position m.


Report •

Ask Question