473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Parsing data from a .dat file and putting the data into Excel

Aloha! I have a data file (.dat) that has about 3000+ lines of data that has the format for the first few characters
Expand|Select|Wrap|Line Numbers
  1. Position   Field Name   Length   Description
  2. 01-14      Item #       9(14)    Item Number
  3. 15-19      Vendor       9(05)    Vender/Manufacturer ID Number
  4. 20-44      Model #      x(25)    Manufacturer Model Number
  5. 45-60      UPC          9(16)    Universal Product Code
  6. 61-62      Buy Dept     x(02)    Wholesale buying department
It actual goes to 500 characters in each lines with 70 different fields.

Can someone please help me out and start me out in how to go about parsing the data automatically and put the data in respective fields (or columns) for each item number in Excel? Or maybe the program will automatically create a file (that is delimited that can then be imported into Excel?

Mahalo! I really don't want to count each record byte by byte.
Feb 28 '07 #1
5 6342
Killer42
8,435 Expert 8TB
Does it have to be done in VB? Perhaps you can just do a text import (with fixed-length fields) in Excel.
Feb 28 '07 #2
Does it have to be done in VB? Perhaps you can just do a text import (with fixed-length fields) in Excel.

Thank you for your response. I think I can do it with text import, but how do I automate it every time I get this file (it is a retail store file that has about 500+ fields and headquarters sends the file every week)? There's got to be an easier way.

Mahalo! (Thank you!)
Feb 28 '07 #3
Killer42
8,435 Expert 8TB
Thank you for your response. I think I can do it with text import, but how do I automate it every time I get this file (it is a retail store file that has about 500+ fields and headquarters sends the file every week)? There's got to be an easier way.
Well, I just started recording a macro then imported a text file, defining some fixed-width fields. Here is what was generated. This should give you some info to work from...
Expand|Select|Wrap|Line Numbers
  1. Workbooks.OpenText Filename:="C:\Sample.TXT", Origin:=xlMSDOS, StartRow _
  2.     :=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(2, 2), Array( _
  3.     6, 1)), TrailingMinusNumbers:=True
If you need to know more about the parameters, look them up, or try importing with different settings and see what changes in the recorded macro.
Feb 28 '07 #4
Well, I just started recording a macro then imported a text file, defining some fixed-width fields. Here is what was generated. This should give you some info to work from...
Expand|Select|Wrap|Line Numbers
  1. Workbooks.OpenText Filename:="C:\Sample.TXT", Origin:=xlMSDOS, StartRow _
  2.     :=1, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), Array(2, 2), Array( _
  3.     6, 1)), TrailingMinusNumbers:=True
If you need to know more about the parameters, look them up, or try importing with different settings and see what changes in the recorded macro.

Mahalo!
I think you and I were on the same page! I tried importing it with the macro recording on and after several times I think I have it all finished the parsing correctly! Thank you sooo much for steering me in the right direction!!!
Feb 28 '07 #5
Killer42
8,435 Expert 8TB
Mahalo!
I think you and I were on the same page! I tried importing it with the macro recording on and after several times I think I have it all finished the parsing correctly! Thank you sooo much for steering me in the right direction!!!
Glad to help! :)
Feb 28 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Phil Powell | last post by:
What would one best recommend to parse an existing Excel spreadsheet (was done in Excel 97 or 2000 not sure to be honest)? I am looking for the most practical way of parsing an existing...
7
by: Kylotan | last post by:
I have a text file where the fields are delimited in various different ways. For example, strings are terminated with a tilde, numbers are terminated with whitespace, and some identifiers are...
7
by: Hugh McLaughlin | last post by:
Hello Everyone and thanks for your help in advance. I am working on an application that requires the parsing of an Excel spreadsheet that will be loaded into a SQL Server table. An example of...
1
by: Andre Ranieri | last post by:
I'm having trouble programatically inserting an Excel file into an Image column in our CRM package's SQL 2000 database. The function appears to work ok, but when I attempt to access the file through...
7
by: jetaw03 | last post by:
guys, can you help me to get data from a text file and putting it in an excel file? my programming language is visual basic 6.0 here is a sample data from the text file: ...
0
by: jetaw03 | last post by:
guys, i need help in using VB 6.0.can you help me to get a data from an excel file from ms access and put it in ms excel..pls help me guys.. here is the sample of the file in access: sum1 sum2...
22
by: JJ | last post by:
Whats the best way for me to pull out records from a tab delimited text file? Or rather HOW do I parse the text, knowing that the tabs are field delimiters and a return (I image) signifies a new...
8
by: Bruce_Stough | last post by:
I am currently using Control.DoDragDrop to drop a text string into Excel. I use the following code DataObject dd = new DataObject();...
2
by: treybraid | last post by:
My Flash file is a GameCenter where team standings are kept.. I have it set up right now with the master spreadsheet programmed that is linked to a dummy sheet that is saved as a CVS doc and loaded...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.