?
Solved

How to Create a DAT file

Posted on 2007-10-12
14
Medium Priority
?
4,180 Views
Last Modified: 2008-03-24
I have an excel file that I need to save as a DAT file.  Can you please show me how to convert the excel file to DAT or create a DAT file?  I am familiar with some visual basic scripting.
0
Comment
Question by:smcfarla
  • 7
  • 3
  • 2
  • +2
14 Comments
 
LVL 16

Expert Comment

by:Calvin Brine
ID: 20067709
I've read a few different comments about .dat files.  It seems to be an extension that is in general use for many different formats of files.  You will need to tell us a little more about the .dat file.  What package produced the file, is it a text based file?

Cal
0
 
LVL 20

Expert Comment

by:Serena Hsi
ID: 20069733
Well, regardless of what application was used to produce the DAT file, Excel's steps to read it are as follows:

Select "File" from the main menu.
Choose "Open" from the drop-down menu.
Click the arrow to the right of the "Look In" box, select the drive and folder where the file is located.
Double click on the file name.
Follow the instructions in the Text Import Wizard to specify how you want to divide the text into columns.

If you have Excel 2003 or an earlier version, you'll be limited to opening 65,536 rows. With Excel 2007 that limit is raised to 1 million rows or so.

If you want sample DAT files to play with, you can download them from the MyFlorida website. However, how this site manages its text-based outputs might be different than your DAT files. These appear to be fixed-width text files.

I haven't used these, but you could try a DAT-to-Excel file converter:
http://www.soft411.com/software/excel-to-dat.html
http://411.myflorida.com/phonebook/index.html
0
 
LVL 70

Expert Comment

by:KCTS
ID: 20069791
a DAT file for what? What application is supposed to read this file?
Most DAT files are csv files - use file Save As  and select CSV
0
Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

 

Author Comment

by:smcfarla
ID: 20072188
I know how to save an excel file as .csv file.  I need to know "how to save an 'excel file as a 'dat file.

I have an excel file with data in it (C:\My Documents\"humana.xls"). The end user requires the file format as .dat version. I would like to simply save my humana.xls file as humana.dat.  If this is too complicated, I'll need to create a dat file and then add data in it.
0
 

Author Comment

by:smcfarla
ID: 20075912
help?
0
 
LVL 16

Accepted Solution

by:
Calvin Brine earned 1500 total points
ID: 20077767
smcfarla,
  As I stated in my first post, the problem is that there is no standard DAT file.  A CSV file has a specific format, an xls file has a specific format, DAT does not.  It's used for many different applications, and each one uses them in different ways and different formats.  Most are really just CSV files with a .dat extension, but that's not always the case.  You need to let us know what the actual file specifications are, or what package is using this file,  in order for us to help you.

0
 

Author Comment

by:smcfarla
ID: 20082316
Here is the file specification:

File Specs
- No Header Record
- Fields seperated by |
- Field sequence must match below
- Last record on file must be $EOF

File Field Sequence Required      
DATE      MM/DD/YYYY
ID      "0"
NAME      
GROUP      
OFF      
NC      
NCH      
NCA      
ASA      
SPAN      
ATIME      
ABTIME      
HTIME
AHTIME
TTTIME
WTIME      "LEAVE BLANK"
SPAN
AN20
AB20
AHOLD
AHOTIME

0
 

Author Comment

by:smcfarla
ID: 20082438
the application I'm using is .csv.  Can you help?
0
 
LVL 16

Expert Comment

by:Calvin Brine
ID: 20085523
smcfarla,
  That information is a great start.  We now know what the output from your excel file needs to look like.  The only problem is that is not a supported excel output format.  That means that we will need to make something in VBA to get this output type.  You are going to need to provide us with a list of your Excel data, and which columns your output data exists in.


example  
Data starts on row 2.
DATE      MM/DD/YYYY - Default value(Today)
ID      "0"  -Default Value(0)
NAME      -Column A
GROUP    -Column B
OFF       - Column C
NC     -Column D

Etc...

HTH
Cal
0
 

Author Comment

by:smcfarla
ID: 20096510
The data in columns B-E & P( leave column P "WTIME" BLANK) will remain the same
The DATE (column A) should reflect the previous day's date.
The data in the other fields changes daily.
  A                  B                 C                   D                   E                  F                    G                    H      
1 DATE        ID      NAME           GROUP         OFF             NC                  NCH            NCA      
2 10/16/2007        0      humana      A      A-1                  
3 10/16/2007        0      humana      B      B-2                  
4 10/16/2007        0      humana      C      C-3                  
5 10/16/2007        0      humana      D      D-4                  
6 10/16/2007        0      humana      E      E-5

 
0
 

Author Comment

by:smcfarla
ID: 20096624
I just attached a copy of the file @ http://www.ee-stuff.com/Expert/Upload/upload.php.

The filename is book25 under "How to create a DAT file".
0
 

Author Comment

by:smcfarla
ID: 20103028
Do you need more information?
0
 
LVL 33

Expert Comment

by:Jeroen Rosink
ID: 20103187
I tried to download the file, only you posted the link were to upload the file, not the link were the file is located.
0
 
LVL 33

Expert Comment

by:Jeroen Rosink
ID: 20103298
You might try to work with a macro like this:

Sub WriteToDatFile()
Dim FileNum As Integer, i As Long
    If Dir("C:\temp\TEXTFILE.DAT") <> "" Then
        ' deletes the file if it exists
        Kill "C:\temp\TEXTFILE.DAT"
    End If
    FileNum = FreeFile ' next free filenumber
    Open "C:\temp\TEXTFILE.DAT" For Output As #FileNum
    ' creates the new file
    'Open "C:\FOLDERNAME\TEXTFILE.TXT" For Append As #FileNum
    ' appends the input to an existing file
    ' write to the textfile
    RowsA = Cells(Rows.Count, 1).End(xlUp).Row
    ColsCount = ActiveSheet.UsedRange.Columns.Count
    For i = 2 To RowsA
        For j = i To ColsCount
             If tmpval = "" Then
                tmpval = Cells(i, j)
             Else
                tmpval = tmpval & "|" & Cells(i, j)
             End If
        Next j
    'Write #FileNum, tmpval
    Print #FileNum, tmpval
    tmpval = ""
    Next i
    Close #FileNum ' close the file
End Sub


to use this macro:
1. Open VBA editor (ALT+F11)
2. insert new module
3. paste code
4. alter location and file name, currently set as: "C:\temp\TEXTFILE.DAT"
5. select sheet where data is stored
6. run macro

I hope this works for you
regards,
Jeroen
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lost Word File? Eagerly, need it back? Read ahead; this File Recovery guide is for you.
This holiday season, we’re giving away the gift of knowledge—tech knowledge, that is. Keep reading to see what hacks, tips, and trends we have wrapped and waiting for you under the tree.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

862 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question