Author Topic: BASIC Question - Creating a Data File.  (Read 835 times)

0 Members and 1 Guest are viewing this topic.

Offline Bryce

  • The Hardware Guy.
  • Supporter
  • 6128 Plus
  • *
  • Posts: 11.752
  • Country: wf
  • It's not broken, it just hasn't been fixed yet.
    • index.php?action=treasury
  • Liked: 4229
  • Likes Given: 445
BASIC Question - Creating a Data File.
« on: 23:22, 16 October 11 »
Hi All,
       I decided to refresh my BASIC skills (or lack of them). I fished out all my old BASIC Progs from my youth and have decided to update some of them. Here's my (current) problem, that maybe someone can solve for me:

I have a database program that reads data from a file using the standard openin/openout. I don't have the original data file any more, but I do have the same data on the PC as a CSV file. How can I get this file back to a DAT file, is there any way to convert the file, copy/paste it or do I have to type it all in again? I have a basic program to manually input the data, but that would take ages.

Bryce.

Offline SyX

  • 6128 Plus
  • ******
  • Posts: 1.129
  • Country: br
  • Liked: 1118
  • Likes Given: 1871
Re: BASIC Question - Creating a Data File.
« Reply #1 on: 00:23, 17 October 11 »
I don't remember how the basic storage the datas in the file (sequential, i suppose), but if you insert a pair of records with your basic program and give me the DAT file generated and a pair of lines of the CSV file, i could hack a python program to convert from your CSV file to DAT ;)

Other option is precede every line of the CSV file with DATA, go to WinApe write "auto 10,10", then select autotype and paste the CSV file (use frameskip 50 and turbo mode for accelerate the process), when is finished you can add a routine to READ from the DATA lines and write in the DAT file ;) (other variation of this technique is reorganizing the CSV file, paste in auto type and you could use your INPUT program to insert the datas automatically)

Offline ralferoo

  • Supporter
  • 6128 Plus
  • *
  • Posts: 969
  • Country: gb
  • Liked: 583
  • Likes Given: 222
Re: BASIC Question - Creating a Data File.
« Reply #2 on: 03:00, 17 October 11 »
My approach would be to use something like 2cdt to turn the CSV file into a binary tape image. Load that into memory and then use peek to read the data and write it back to a file on disk using openout. It's probably also possible to skip the peeking and create a stream tape file directly, but I don't know the specifics of how it encodes the data (at the very least, it'd use a different file type byte).

It's also possible you might not have much success with 2cdt as distributed. I basically rewrote the innards of it because it did something wrong (although I can't remember what), so if it doesn't do what you need, I can package up my source tree for that.

Offline HAL 6128

  • 6128 Plus
  • ******
  • Posts: 514
  • Country: de
    • index.php?action=treasury
  • Liked: 254
  • Likes Given: 1333
Re: BASIC Question - Creating a Data File.
« Reply #3 on: 10:45, 17 October 11 »
The openin/openout command read datas in sequence. Each data will be seperated with an &13 (Return?) - but I'm not sure about that.
It depends how is the CSV-file built. If the datas are among each other just copy the datas into notepad and save the file as an ASCII, and put on as DSK via ManageDSK?
...proudly supported Schnapps Demo, Pentomino and NQ-Music-Disc with GFX

Offline Zetr0

  • CPC664
  • ***
  • Posts: 72
  • Country: gb
    • AmiBay
  • Liked: 33
  • Likes Given: 14
Re: BASIC Question - Creating a Data File.
« Reply #4 on: 22:12, 17 October 11 »
Well this is very interesting,

After spending this last week in Hospital I managed to get some reading done, one of them was the Amstrad CPC464 Intruction to programming manual...

just refreshing my memory and I shall post back shortly =D
If I had a hammer.....