Windows 7 Forums

Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.


Windows 7: DBF to CSV in batch: how to do?

11 Aug 2014   #1
sev7en

Windows 7
 
 
DBF to CSV in batch: how to do?

Dear Community,
I need to convert every minute (1 minute) a file generate in format DBF into the CSV format. I looked around some script, I found one script in Python but unfortunately it doesn't work.

Can you help me?


Cheers,


My System SpecsSystem Spec
.
11 Aug 2014   #2
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Quote   Quote: Originally Posted by sev7en View Post
Dear Community,
I need to convert every minute (1 minute) a file generate in format DBF into the CSV format. I looked around some script, I found one script in Python but unfortunately it doesn't work.

Can you help me?


Cheers,
What program does create the DBF file each minute?
My System SpecsSystem Spec
11 Aug 2014   #3
sev7en

Windows 7
 
 

Good afternoon,
thanks for the prompt reply. It is a internal monitor application for enviromental data mining. I have uploaded it here: https://www.m-e-d-i-a-f-i-r-e.com/?a2nn9ihat6zs90k


Cheers,
My System SpecsSystem Spec
.

11 Aug 2014   #4
Kaktussoft

Microsoft Community Contributor Award Recipient

Microsoft Windows 7 Home Premium 64-bits 7601 Multiprocessor Free Service Pack 1
 
 

Can't you simply adjust the "monitor application" so it output to CSV?
Otherwise I don't have a solution.
My System SpecsSystem Spec
11 Aug 2014   #5
sev7en

Windows 7
 
 

Hi, no sorry I cannot...
My System SpecsSystem Spec
11 Aug 2014   #6
Alejandro85

Windows 7 Ultimate x64
 
 

I think Excel can deal with both formats. Do you have it avaiable?
Try opening with Excel, and saving in CSV afterwards, see if the resulting file satisfies your needs.
My System SpecsSystem Spec
11 Aug 2014   #7
sev7en

Windows 7
 
 

Good evening,
yes, Excel is able to handle it but I have to do that via command line, as it's a trigged operation (via file batch).


Regards,
My System SpecsSystem Spec
11 Aug 2014   #8
Alejandro85

Windows 7 Ultimate x64
 
 

Great. Then, it's just a matter of scripting Excel to do the job automatically. For example, you may use VBScript to instruct Excel to load the dbf, then re-save it as csv:

Code:
Const xlCSV = 6

'Open Excel and load dbf within it
Set objExcel = CreateObject("Excel.Application")
objExcel.DisplayAlerts = FALSE
objExcel.Visible = FALSE
Set objWorkbook = objExcel.Workbooks.Open("C:\temp\test.dbf")

'Just save it without any modification, chosing CSV as format
objWorkbook.SaveAs "C:\temp\test.csv", xlCSV
objWorkbook.Close

'Close Excel and quit
objExcel.Quit
WScript.Quit
Save this as a .vbs file. It can be called directly from command line afterwards, included in a .bat file, scheduled task or whatever.

Be sure to fully test it on real sample data, I've just played with it a little. While I think it's a reasonably good approach, it's definitely not production quality. For instance, it lacks error handling . But you may be able to tune this to your exact needs.
My System SpecsSystem Spec
11 Aug 2014   #9
sev7en

Windows 7
 
 

Dear Alejandro85,
thank you! The script is working like a charm but I have a problem: the file keep opened in the application and I cannot copy or overwrite it again.
Does it is a way to kill Excel after the conversion automatically? That script should be executed every 60 seconds.
My System SpecsSystem Spec
12 Aug 2014   #10
sev7en

Windows 7
 
 

Dear Alejandro,
I just added that to avoid the security warning when the script is launched...

Quote:
set oShell= CreateObject("Wscript.Shell")
set oEnv = oShell.Environment("PROCESS")
oEnv("SEE_MASK_NOZONECHECKS") = 1
oShell.Run "script.vbs /norestart",0,True
oEnv.Remove("SEE_MASK_NOZONECHECKS")
but now we have to fix the issues of the message above as well the one for the security warning as the script is executed on a network drive.
My System SpecsSystem Spec
Reply

 DBF to CSV in batch: how to do?




Thread Tools Search this Thread
Search this Thread:

Advanced Search




Similar help and support threads
Thread Forum
batch script help
dear all any help to make batch script this the reason i want to make a batch file is to help me update the online games in 60 computers by overwriting or copying big files in one click from 1 source computer... instead of turning on all 60 computers and updating all online games, he'll just...
General Discussion
How to run a batch file at logoff & some batch scripting help please
Hiya, I'd just like to run a simple batch file at logoff to backup some settings. I plan to use Robocopy, which is what i use to more thorough backups. Two questions: 1. How make it run by clicking Start > Shutdown? (i realise i could make a shutdown batch file and run it instead, but i'd...
Backup and Restore
Need some help on cmd batch file.
Hi, I would like to a batchfile that will work on both windows 7 and xp to do the following copy /Y d:\document\folder1\file.ini d:\document\folder2\file.ini however in xp it is my document, win7 is document the shell command in win7
General Discussion
Batch File that grabs file names from folder to insert into batch file
Ok I'm totally at a loss on how to word this so I'm just going to write it out the best that I can... :confused: First I have a batch file that I'm writing that will convert mp4 files to mp3 files (I have a lot) for a buddies band using ffmpeg. Here's the code that I'm using: ffmpeg -i...
General Discussion
In need of help doing a FOR /F Do loop in a CMD Batch
I am in need of help doing a FOR /F Do loop in a CMD Batch script. I am trying to write a batch script that will ping all IP addresses in a host file except for an IP address that starts with 127 and skip all commented lines in the hostfile or that start with a #. my current code will ping...
General Discussion
batch files
Can I write simple batch files - example - at 3am xcopy server file to workstation a ?
Software


Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 15:50.

Twitter Facebook Google+



Windows 7 Forums

Seven Forums Android App Seven Forums IOS App