<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic shell script for converting a foxbase .DAT file to (comma delimited) .CSV using excel in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/shell-script-for-converting-a-foxbase-DAT-file-to-comma/m-p/226348#M44224</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm kind of new to this, so please bear with me. I have been trying to make a shell script that can do the following:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;convert a FoxBase v3.0 .DAT file into a comma delimited .csv file.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I decided to go with a VBScript and this the code that I have so far. So far what I've come up with is a corrupt .csv file. When I add it to Splunk! it reads as corrupted and not a (comma delimited) csv file. I was hoping to get some pointers.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("D:\_Work\_Splunk\Villarica\LC8.DAT")
objExcel.Application.DisplayAlerts = False
objExcel.Application.Visible = True

objExcel.ActiveWorkbook.SaveAs "D:\_Work\_Splunk\Villarica\LC8.CSV"
objExcel.ActiveWorkbook.Close

objExcel.Application.Quit
WScript.Echo "Finished."
WScript.Quit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Even if you don't have an answer thanks for taking a look.&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jan 2017 07:20:37 GMT</pubDate>
    <dc:creator>Nanuk</dc:creator>
    <dc:date>2017-01-11T07:20:37Z</dc:date>
    <item>
      <title>shell script for converting a foxbase .DAT file to (comma delimited) .CSV using excel</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/shell-script-for-converting-a-foxbase-DAT-file-to-comma/m-p/226348#M44224</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I'm kind of new to this, so please bear with me. I have been trying to make a shell script that can do the following:&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;convert a FoxBase v3.0 .DAT file into a comma delimited .csv file.&lt;/LI&gt;
&lt;/UL&gt;

&lt;P&gt;I decided to go with a VBScript and this the code that I have so far. So far what I've come up with is a corrupt .csv file. When I add it to Splunk! it reads as corrupted and not a (comma delimited) csv file. I was hoping to get some pointers.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Set objExcel = CreateObject("Excel.Application")
Set objWorkbook = objExcel.Workbooks.Open("D:\_Work\_Splunk\Villarica\LC8.DAT")
objExcel.Application.DisplayAlerts = False
objExcel.Application.Visible = True

objExcel.ActiveWorkbook.SaveAs "D:\_Work\_Splunk\Villarica\LC8.CSV"
objExcel.ActiveWorkbook.Close

objExcel.Application.Quit
WScript.Echo "Finished."
WScript.Quit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Even if you don't have an answer thanks for taking a look.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2017 07:20:37 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/shell-script-for-converting-a-foxbase-DAT-file-to-comma/m-p/226348#M44224</guid>
      <dc:creator>Nanuk</dc:creator>
      <dc:date>2017-01-11T07:20:37Z</dc:date>
    </item>
    <item>
      <title>Re: shell script for converting a foxbase .DAT file to (comma delimited) .CSV using excel</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/shell-script-for-converting-a-foxbase-DAT-file-to-comma/m-p/226349#M44225</link>
      <description>&lt;P&gt;I was able to figure out my mistake I'll post the correct code below.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;'Declaring Constants
Const ForReading = 1, ForWriting = 2, ForAppending = 3
'Declaring Variables
dim fso, strDirectory, strOutPut, fLocation, fNewName, objWorkbook, local
local = true

Set objExcel = CreateObject("Excel.Application")
Set fso = CreateObject("Scripting.FileSystemObject")
objExcel.Application.DisplayAlerts = False
objExcel.Application.Visible = False

'Open Text Files for use
Set strDirectory    = fso.OpenTextFile("D:\_Work\_Splunk\_TestBed\DATFileLocations.txt", ForReading, TristateFalse)
Set strFileName     = fso.OpenTextFile("D:\_Work\_Splunk\_TestBed\csvFileNames.txt", ForReading, TristateFalse)

Do Until strDirectory.AtEndOfStream
  fLocation = strDirectory.ReadLine     'Get the location of the DAT file
  fNewName = strFileName.ReadLine       'Get the name of the target csv file
  Set objWorkbook = objExcel.Workbooks.Open(fLocation) 'Open the DAT file
  objExcel.ActiveWorkbook.SaveAs fNewName, 6    'Save the DAT file as a csv
  objExcel.ActiveWorkbook.Close
Loop

'Close the text files'
strDirectory.Close
strFileName.Close
'Set strDirectory = Nothing
'Set strFileName = Nothing
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 13 Jan 2017 07:59:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/shell-script-for-converting-a-foxbase-DAT-file-to-comma/m-p/226349#M44225</guid>
      <dc:creator>Nanuk</dc:creator>
      <dc:date>2017-01-13T07:59:18Z</dc:date>
    </item>
  </channel>
</rss>

