.dat problems

have a serious problem - that's endangering a project of mine -
I have to mine out the data of the attached file (and many others like 'em)

the file is a TURBO PASCAL file (version 7 "I BELIEVE") and I'm wondering if anybody can tell me how go get it to a ".csv", ACSII text, or anything I can read - and no I don 't have any table layouts and the original PROGRAMMER did not work out

If I can see the data I believe I can figure out the layout and then get them to a .mdb  or something that my new code can read
I will rename the file to a .txt so I can upload.
 the file is a ".dat" originally
OPCODE---Copy.txt
MBHEY131Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Walter RitzelSenior Software EngineerCommented:
Ok, so when you say it is a TURBO PASCAL file, it means exactly what? It is a source code file, a binary, etc? or it is an output file generated by a program written in TURBO PASCAL 7?

If it is the latter, you should get the source code of the program to understand the structure and then write something to convert that.
MBHEY131Author Commented:
Ok, so when you say it is a TURBO PASCAL file, it means exactly what?
++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A data file - where the data (output file I guess your referring too) stored after customer setup and input-I know next to nothing about PASCAL!! .DAT FILE
=================================================================================
If it is the latter, you should get the source code of the program to understand the structure and then write something to convert that.
+++++++++++++++++++++++++++++++++++++++
I have exhausted all avenues to get this code or structure makeup? - is there no way to get at the raw data - I find that hard to believe in this day and age!!
==================================================================================
Walter RitzelSenior Software EngineerCommented:
I have exhausted all avenues to get this code or structure makeup? - is there no way to get at the raw data - I find that hard to believe in this day and age!!
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Yes, at this day and age, there are still some things that we can't do... So, let me explain: a .dat extension in a file means nothing. This .dat file is a binary file, and the structure saved there could be anything, depending on the code used to write it. Anyway, I'm looking into some options.
Need More Insight Into What’s Killing Your Network

Flow data analysis from SolarWinds NetFlow Traffic Analyzer (NTA), along with Network Performance Monitor (NPM), can give you deeper visibility into your network’s traffic.

Walter RitzelSenior Software EngineerCommented:
Ah,
I found something interesting.

This website seems to be capable of analyze a file and say which type of file it may be: http://mark0.net/onlinetrid.aspx

Please try and let us know if that have worked for you.
Walter RitzelSenior Software EngineerCommented:
And one more link: http://filext.com/faq/look_into_files.php
Article about file identification. May point you to other resources.
Sinisa VukSoftware architectCommented:
Which programming language/tool you use (or planning) ? Turbo Pascal?
MBHEY131Author Commented:
my problem is that I cannot mine the data from a ".dat" file (which is a "TURBO PASCAL" VERSION 7 I THINK!) as I know next to nothing about Pascal at all, I am in the process of upgrading several apps of mine "which I need this old data to complete the upgrade" I am currently programming in VISUAL STUDIO 2012 VB.NET - I HAVE NO WAY OF GETTING THE OLD .PAS FILE'S "AS OF NOW"
Walter RitzelSenior Software EngineerCommented:
And what about the links I've posted? Did you try to use the apps indicated there?
MBHEY131Author Commented:
I'm not interested in "FILE IDENTITY" "I know it's a pascal data file" as I have said many times - and I can do a google search without coming to the experts exchange - I want "some answers"  to get at the data!
Walter RitzelSenior Software EngineerCommented:
So, you want some answers to get at the data. Then answer this, first: what kind of data structure is stored on this file? Or this is a case of "the data is important but I dont what it means..."
_Commented:
Like already mentioned, "mining" this is going to be next to impossible, without the actual program (source code would be better) to deconstruct.

You can try running the .DAT file through a Hex Editor, and see what it says (don't bother running the text file you posted. it just shows the plain text parts):

Free Hex Editor Neo
http://www.hhdsoftware.com/free-hex-editor

If you do have the program, you could do it "old school". Print out the files, and have somebody re-enter the data in the new program.

Other than that, you are pretty much pooched.   sorry.
I will poke around a little bit more, but don't hold your breath.

others with the same issue:
http://www.delphigroups.info/2/36/759.html
http://www.delphigroups.info/2/11/2959.html


You can also look through the Hire an Expert section, and see if anybody can help. Use the Edit Search to cut down the number of people to sort through.
http://www.experts-exchange.com/memberSearchResults.jsp?searchHireEnabled=true&sort=100_-1&searchTitle=For%20Hire
Walter RitzelSenior Software EngineerCommented:
Also, the file you posted, if read byte by byte by other programming languages (c# and python), is full of nulls. So, if this is your original .dat file, it could mean this file is basically with no valuable data.
MBHEY131Author Commented:
So, you want some answers to get at the data. Then answer this, first: what kind of data structure is stored on this file? Or this is a case of "the data is important but I dont what it means..."
++++++++++++++++++++++++++++++++++++++++++++++++
See Above as I'm not posting the facts again. - if you can't help with data presented "which I already said is all I have" then I wish you would just say so.!!
==============================================
coral472015-05-08 at 11:44:25ID: 40767434
Like already mentioned, "mining" this is going to be next to impossible, without the actual program (source code would be better) to deconstruct. - I have the actual Program "you mean app?" if you can't help with data presented "which I already said is all I have" then I wish you would just say so.!!

 You can try running the .DAT file through a Hex Editor, and see what it says (don't bother running the text file you posted. it just shows the plain text parts):
WITCH IS ALL I NEED (IS THE TEXT) TO POUR INTO THE NEW .MDB FILES FOR MY NEW APP!!

 Free Hex Editor Neo
http://www.hhdsoftware.com/free-hex-editor
+++++++++++++++++++++++++++++++++++++++++
as I said earlier - it's just a rename of the .dat file????
===============================================
You can also look through the Hire an Expert section
+++++++++++++++++++++++++++++++++++++++++++++++
thought I already HIRED an expert at "EXPERTS" EXCHANGE
I SEE NOW that's far from the truth.!!
===============================================
Walter Ritzel2015-05-08 at 11:51:01ID: 40767443
Also, the file you posted, if read byte by byte by other programming languages (c# and python), is full of nulls. So, if this is your original .dat file, it could mean this file  is basically with no valuable data.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
I know it's got good data - if, it could never mind! - if you can't help me - well I guess just say so!!
=================================================================================

maybe I can somehow print it to an .csv or ascii file - thanx for your time
MBHEY131Author Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for MBHEY131's comment #a40767507

for the following reason:

BECAUSE IT'S THE ONLY OWN THAT HAS A CHANCE OF WORKING
Walter RitzelSenior Software EngineerCommented:
I think you should start to tone down a little bit and remember your good manners. You have Experts here working voluntarily on your problem and giving you answers (even if you dont like the answers at all). Also, if you dont have the knowledge to understand what we have explained, instead of attacking us, you should be more polite and ask for more clarification.

Getting back to your problem, here is the situation why it is very difficult to proceed without knowing the record structure used to save information on the file: As you may know from other programming languages, and it is valid for Pascal too, one of the methods to persist data is to save in binary files (the .dat).Usually this is done persisting an object of a given type (in Pascal is the record type).  See the code below: we need to know the record type used to save the information to try to extract. Because of that we need the source code. There is no magic, just plain old coding. About the nulls I have mentioned before, I was not correct. Here is your file treated to extract all readable characters possible. It was possible to distinguish at least on string field inside, so I have broke in one per line.

 type
   Scores = record
     name: string[50];
     score: integer;
   end;  

var rank: array[1..3] of scores;

...

var
  i: Integer;
  myFile: File of TScores;
begin
  AssignFile(myFile,'Rank.dat');
  Rewrite(myFile);

  try
    for i := 1 to 3 do
      Write(myFile, Rank[i]);
 finally
   CloseFile(myFile);
 end;
end; 

...

var
  i: Integer;
  Scores: TScores;
  myFile: File of TScores;
begin
  AssignFile(myFile, 'Rank.dat');
  Reset(myFile);

  try
    i := 1;
    while not EOF(myFile) do 
    begin
      Read(myFile, Scores);
      Rank[i] := Scores;      //You will get an error if i is out of the array bounds. I.e. more than 3
      Inc(i);
    end;
  finally
   CloseFile(myFile);
  end;
 end; 

Open in new window


And your reason to close this question is totally unnaceptable.
Walter RitzelSenior Software EngineerCommented:
The reason provided by OP is not acceptable, as answers were provided.
Walter RitzelSenior Software EngineerCommented:
Here is the file.
OPCODE.txt
MBHEY131Author Commented:
that's all I need - I should be able to parse out and pour into the new file for the upgraded version of the app -

 and I do apologize for getting out of line - but remember I did ask for this exact data quit a few days ago, and you lead me to believe that it was not possible with the data I provided

and I have many more files (20 or so) but I do know what this file (or data therein) that you sent me represents

but I still am a little green with VS 2012 but I do feel this will solve my problem -

you may be voluntary but I paid good money for your service and I may need some assistance
with the future files maybe, as I am not sure I totally understand your coding.

 - thanx again!!
Walter RitzelSenior Software EngineerCommented:
If you pay or not should not influence your way to deal with others: with respect. But that is water under the bridge.

But I want to make it clear: although I have provided you with the data you want, I still say that is not possible to give you exactly what you want without the source code. What you have received is just descriptions of something. And what about all the rest of data that exists there?

About my code, The example I put above is Pascal. If you want the code that have generate the translated file, please let me know. It is python, very simple. And I believe it can run on VS2012.
MBHEY131Author Commented:
no it's not exactly what I want but I am sure it's more than good enough - yes give the code (with a brief explanation of how  to (transform to text) from the other files if you would) or I can send you a zipped up file with the other .dat's in them. - or can you give me some VB.NET code as I am becoming more familiar with that.
MBHEY131Author Commented:
here is the first zipped file that I need converted to the ascii or .txt file that you converted earlier
DatsZip.zip
MBHEY131Author Commented:
OK - very good the zip is there also - now that all we need to do is run the files though that chuck of python code as I understand!! - we should be able to get that done pretty soon, right?
Walter RitzelSenior Software EngineerCommented:
Yes, I'm making some adjustments on the script and you will be able to run it by yourself.
In the meantime, please go ahead to the following website: http://www.python.org and download the latest 2.7.X version of python for Windows.
MBHEY131Author Commented:
alright
Walter RitzelSenior Software EngineerCommented:
Here is the script. To use, the command line is:
python convert_dat_file.py <name of the dat file> <name_of_converted_file>

This assumes that you have installed python on your system and it is configured on your system path variables.
In case of not be configured on your system path variables, use like this:
<drive>:<\path\to\python>\python convert_dat_file.py <name of the dat file> <name_of_converted_file>
convert-dat-file.py
MBHEY131Author Commented:
thank you for this file - I will let you know how the conversion goes.
MBHEY131Author Commented:
Python 2.7.9 (default, Dec 10 2014, 12:24:55) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> python convert_dat_file.py disc.dat disc.txt
SyntaxError: invalid syntax
>>> python convert_dat_file.py disc.dat disc.txt
SyntaxError: invalid syntax
>>> \python convert_dat_file.py disc.dat disc.txt
SyntaxError: unexpected character after line continuation character
>>> \python convert_dat_file.py disc.dat disc.txt
SyntaxError: unexpected character after line continuation character
>>> \python convert_dat_file.py disc.dat disc.txt\
	
SyntaxError: unexpected character after line continuation character
>>> \python convert_dat_file.py disc.dat disc.txt.
SyntaxError: unexpected character after line continuation character
>>> c:\python27\ python convert_dat_file.py disc.dat disc.txt etc does not work either

Open in new window


I am doing something wrong and I cannot figure it out

1. Python Installed (CORRECTLY I BELIEVE)
2. Copied down and the file "convert_dat_file.py" appears OK
3. Copied at put "Disc.dat" into "c:\python27 folder"

But still get the errors above???
Walter RitzelSenior Software EngineerCommented:
Ok, by the output of the problem, you did a very common mistake: you have opened the python console and were trying to execute a command line on it.

Please follow these steps:

1) Dont copy any files to c:\python27 folder;
2) Create a work folder in any place of your hard drive;
3) Open a command prompt and navigate to the work folder;
4) Type the following command: python --version
5) You should see the following output: Python 2.7.9. If you dont see the output, it means that Python folder is not on your system path. You need to fix that until this step works.
6) Copy the .dat file to the work folder
7) Then, on the command prompt, type the following command: python convert_dat_file.py <filename> <outputfilename>
MBHEY131Author Commented:
Microsoft Windows [Version 6.3.9600]
(c) 2013 Microsoft Corporation. All rights reserved.

C:\Windows\System32>cd\wrkngpythn

C:\wrkngPythn>python --version
Python 2.7.9

C:\wrkngPythn>python convet_dat_file.py disc.dat disc.txt
python: can't open file 'convet_dat_file.py': [Errno 2] No such file or director
y

C:\wrkngPythn>python convert_dat_file.py disc.dat disc.txt
python: can't open file 'convert_dat_file.py': [Errno 2] No such file or directo
ry

C:\wrkngPythn>python convert_dat_file.py disc.dat disc.txt
  File "convert_dat_file.py", line 3
    import traceback line_break_char = 20 invalid_char = 0
                                   ^
SyntaxError: invalid syntax

C:\wrkngPythn>python convert_dat_file.py disc.dat disc.txt
  File "convert_dat_file.py", line 1
    import sys import traceback line_break_char = 20 invalid_char = 0 def open_d
at_file(sourceFile, targetFile): try: f = open(sourceFile,'r') fw = open(targetF
ile,'w') for line in f: for char in line: if len(char.strip()) > 0: if ord(char.
strip()) != invalid_char: if ord(char.strip()) == line_break_char: fw.write('\n'
) else: fw.write(char.strip()) f.close() fw.close() except: print "An exception
occurs. Please see the message below: " print traceback.format_exc() def main(so
urceFile,targetFile): exitCode = 0 try: open_dat_file(sourceFile,targetFile) exc
ept: exitCode = 1 print "An exception occurs. Please see the message below: " pr
int traceback.format_exc() return exitCode # Main program if __name__=="__main__
": exitCode = 0 try: if len(sys.argv) < 3: print 'Correct usage of this script i
s: python convert_dat_file.py ' print ': .dat file to be converted' print ': nam
e of the file for the converted data' exitCode = 1 else: sourceFile = sys.argv[1
] targetFile = sys.argv[2] exitCode = main(sourceFile,targetFile) except: print
traceback.format_exc() exitCode = 1 sys.exit(exitCode)
                    ^
SyntaxError: invalid syntax

C:\wrkngPythn>

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Now I'm at this error (above) - the file convert_dat_file.py does not copy down as usual, but no matter the format it's in I get the Syntax error!!
================================================================
Walter RitzelSenior Software EngineerCommented:
what you mean by do not copy down as usual? python code should be well formatted or it will not work. let me send the file again once I'm at my computer again.
MBHEY131Author Commented:
what you mean by do not copy down as usual?
++++++++++++++++++++++++++++++++++++++++++
when I clicked on the original file of "convert_dat_file.py" a screen full of code with no pattern at all appeared (I then cut and pasted it to a file I named "convert_dat_file.py") it opened up with the IDLE or whatever it was and I reformatted it "by redrawing the lines" and it took on the color function and looked OK - I say that's weird because I'm not used to code behaving that way - not to say it's incorrect because this if my first foray with PYTHON
======================================================================
_Commented:
Try right-clicking the file convert-dat-file.py link > choose Save Link As > then save it to the folder you are working in, or any place where you can find it again, then move it where you need it.

This will save it just the way he scripted it.   ; )
MBHEY131Author Commented:
Try right-clicking the file convert-dat-file.py link > choose Save Link As > then save it to the folder you are working in, or any place where you can find it again, then move it where you need it.

 This will save it just the way he scripted it.   ; )
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
When I Right-Click on "convert-dat-file.py link" " > choose Save Link As >" doesn't appear at all
just Open Link a couple of ways, Copy link, APPEAR (all of which I tried earlier.)
============================================================================
Walter RitzelSenior Software EngineerCommented:
Here is the file zipped. That should overcome the problem with formatting.
convert-dat-file.zip

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
_Commented:
>> ...when I choose Save Link As >" doesn't appear at all

That's odd. Maybe only Firefox has it.    : /
MBHEY131Author Commented:
>> ...when I choose Save Link As >" doesn't appear at all

 That's odd. Maybe only Firefox has it.    : /
++++++++++++++++++++++++++++++++++
yeah, it may be the browswer, but I did get a correctly (as I am familiar with a code file looks) downloaded and I am checking the conversion against the new file now.
======================================================
_Commented:
good deal. I will go back to my corner and be quite, now.
MBHEY131Author Commented:
that worked and I now have a text in a ".txt" file I believe I can work with in VB2012 and may have some ?'s as I have not ventured that way in VB2012 before, but I have experienced this issue "reading text and pouring data into another databases with other languages" but I believe we can close this (question) out as the data is now available (I haven't converted all the data files yet, but don't forsee any more issues along these lines) and it will take some time go traverse this data over to VS2012 databases
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Databases

From novice to tech pro — start learning today.