Liberty BASIC Community Forum
Liberty BASIC Programming Discussions >> Liberty BASIC Code >> unzipping file

unzipping file
Post by Bob on Sep 7th, 2017, 10:31pm

Hello to all,

I am a novice programmer to just about everyone on here and new to this forum. I have used Liberty Basic off and on for over 10 years for the main purpose of writing, using and updating a horse racing handicapping program that I wrote. I learned basic way back in college and never had a good tutorial on using commands to unzip files, calls, dlls, etc. I am currently downloading zipped racing files from a website, unzipping them in winzip, opening the file in excel due to use of commas in the data (original unzipped date file is comma delimited but uses ""), renaming the file and then opening it with my program. I would like to expedite this process. Can anyone direct me to a good link that can teach me how to start the filedialog and open the zip file within my program?

Thank you
Re: unzipping file
Post by robmcal on Sep 8th, 2017, 4:10pm

7-zip has a command line version. You may try using that.
Re: unzipping file
Post by Bob on Sep 8th, 2017, 10:19pm

I have downloaded 7-zip but do not see any tutorials for programming.
Re: unzipping file
Post by robmcal on Sep 8th, 2017, 10:34pm

Not exactly sure how to use it myself. The command line syntax is described on this page.

Re: unzipping file
Post by tenochtitlanuk on Sep 9th, 2017, 2:02pm

If you've downloaded 7za.exe to the directory holding your LB code, try the following which worked for me. Don't know what files are in your zip file nor what you'll do with them. If you KNOW filenames you can now parse them. If not you may need another filedialog to select a file....
There are examples about parsing csv files and delimiter problems around this forum and elsewhere.
    '   7za.exe extracts all files from *.zip to the current directory.


    filedialog "Choose zip file", "*.zip", zipFile$

    run "7za.exe e " +zipFile$


Re: unzipping file
Post by Bob on Sep 9th, 2017, 7:06pm

Thank you tenochtitlanuk

This makes sense to open the zip file into the directory. I could then determine the filename selected as the zip file and unzip file have the same name and automatically select the unzipped file. I'll let you know how this turns out.

My next issue would be reprogramming how I have inputted the unzipped file. While the original unzipped file is comma delimited it does have quotes around the text data (ie "AQU",1,"Track",35). I currently change this file to a csv in excel and input data with simple character for comma to delimit the data. This would not work with the original unzipped file. Any suggestions for an easy correction to the programming code would be helpful.

Re: unzipping file
Post by Rod on Sep 10th, 2017, 02:03am

There is a new inputcsv command which you should experiment with.