summaryrefslogtreecommitdiff
path: root/support/csvtolatex/Source/csvtolatex.vbs
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
committerNorbert Preining <norbert@preining.info>2019-09-02 13:46:59 +0900
commite0c6872cf40896c7be36b11dcc744620f10adf1d (patch)
tree60335e10d2f4354b0674ec22d7b53f0f8abee672 /support/csvtolatex/Source/csvtolatex.vbs
Initial commit
Diffstat (limited to 'support/csvtolatex/Source/csvtolatex.vbs')
-rw-r--r--support/csvtolatex/Source/csvtolatex.vbs152
1 files changed, 152 insertions, 0 deletions
diff --git a/support/csvtolatex/Source/csvtolatex.vbs b/support/csvtolatex/Source/csvtolatex.vbs
new file mode 100644
index 0000000000..86b9cb8203
--- /dev/null
+++ b/support/csvtolatex/Source/csvtolatex.vbs
@@ -0,0 +1,152 @@
+Option Explicit
+
+Const version = "1.1"
+'This is the script-version of csvtolatex version 1.1
+'So you can also use csvtolatex with a configuration file with the extension .ctl
+'for more information see the docimentation
+'Every one who uses this script agrees with the License you find in License.txt.
+'here you write the path and the filename of the input-file you are using.
+Const iPath = "C:\users\documents\inpufile.csv"
+
+
+'here you write the path, where all output-files should be written
+Const ePfad = "C:\users\documents\tables\"
+
+
+
+'here you can switch between text- and mathmode
+'for mathmode it is "$" for textmode it is "":
+Const mode = "$"
+'this is mathmode
+
+
+
+
+'information for inputfile.csv
+
+'every table begins with '/begin{' this defines the outputfile.
+'example: /begin{output1.csv}
+
+'every row in a table has to end with '//' respectivly ';//'
+'if you are using program like MS Excel just write at the end of every row '//'
+
+'every table ends with '/end'
+'example: /end
+
+
+'you may use '\cline' or '/cline' to make a \cline
+
+'you may use '/blank', if a cell has to blank, but
+
+'you can use '/.,' to have a semicolon (';') in your table
+
+
+
+
+
+
+
+'now there is no need to change anything
+Dim index, delete, lineend, zusatztext
+Dim mnumber, worktext, testnumber, zwischen, addition, arbeitstext, geteilt, nCount, indexi, muellzahl, head
+index = "0"
+delete = "@€€@µ"
+
+Dim Fso, iFile, eFile, Text, ePath
+
+
+Set Fso = CreateObject("Scripting.FileSystemObject")
+Set iFile = Fso.OpenTextFile(iPath)
+
+
+Do Until iFile.AtEndOfStream
+ Text = iFile.ReadLine
+ Do While ((InStr(Text, ";//;")))
+ Text = Replace(Text, ";//;", ";//")
+ Loop
+ Text = Replace(Text, ";/endhead", ";// /endhead")
+ Do While ((InStr(Text, "/endhead;")))
+ Text = Replace(Text, "/endhead;", "/endhead")
+ Loop
+ If (InStr(Text, ";//")) Then
+ Dim muell
+ Text = Replace(Text, ";//", "")
+ arbeitstext = ""
+ geteilt = Split(Text, ";")
+ indexi = "0"
+ nCount = UBound(geteilt, 1) - LBound(geteilt, 1) + 1
+ muellzahl = "0"
+ zusatztext = mode
+ Do
+ zwischen = 1
+ 'muell = MsgBox(Text & " >" & geteilt(indexi) & "< " & (Len(geteilt(indexi)) = 0), 0)
+ If InStr(geteilt(indexi), "/multicolumn{") Then
+ mnumber = InStr(geteilt(indexi), "/multicolumn{")
+ testnumber = InStr(geteilt(indexi), "}")
+ addition = "0"
+ zwischen = geteilt(indexi)
+ testnumber = testnumber - 1
+ zwischen = Left(zwischen, testnumber)
+ testnumber = InstrRev(zwischen, "{")
+ testnumber = Len(zwischen) - testnumber
+ zwischen = Right(zwischen, testnumber)
+ geteilt(indexi) = Replace(geteilt(indexi), "/multicolumn{", "\multicolumn{")
+ zusatztext = ""
+ ElseIf InStr(geteilt(indexi), "/multirow{") Then
+ geteilt(indexi) = Replace(geteilt(indexi), "/multirow{", " \multirow{")
+ zusatztext = ""
+ ElseIf ((Len(geteilt(indexi)) = 0) Or InStr(Text, "/cline{") Or InStr(Text, "\cline{")) Then
+ zusatztext = ""
+ Else
+ zusatztext = mode
+ End If
+ testnumber = indexi + 1
+ If InStr(testnumber, nCount) Then
+ arbeitstext = arbeitstext & zusatztext & geteilt(indexi) & zusatztext
+ Else
+ testnumber = indexi + zwischen
+ If (InStr(testnumber, nCount) And InStr(geteilt(indexi), "\multicolumn{")) Then
+ arbeitstext = arbeitstext & zusatztext & geteilt(indexi) & zusatztext
+ Else
+ arbeitstext = arbeitstext & zusatztext & geteilt(indexi) & zusatztext & "&"
+ End If
+ End If
+ indexi = indexi + zwischen
+ Loop Until (InStr(indexi, nCount))
+ Text = arbeitstext
+ head = " "
+ If InStr(Text, "/endhead") Then
+ Text = Replace(Text, "/endhead", "")
+ head = " \endhead "
+ End If
+ lineend = "\hline"
+ If InStr(Text, "/cline{") Then
+ Text = Replace(Text, "/cline{", "\cline{")
+ End If
+ If InStr(Text, "\cline{") Then
+ mnumber = InStr(Text, "\cline{") - 1
+ arbeitstext = Left(Text, mnumber)
+ zwischen = Replace(Text, arbeitstext, "")
+ lineend = zwischen
+ Text = arbeitstext
+ End If
+ Text = Replace(Text, "/.,", ";")
+ Text = Text & "\\ " & lineend & head
+ Text = Replace(Text, "&" & mode & "/blank", "&")
+ Text = Replace(Text, "&" & "/blank", "&")
+ eFile.WriteLine Text
+ End If
+ If InStr(Text, "/begin{") Then
+ Text = Replace(Text, "/begin{", "")
+ Text = Replace(Text, ";", "")
+ ePath = ePfad & Replace(Text, "}", "")
+ Set eFile = Fso.CreateTextFile(ePath)
+ End If
+ If InStr(Text, "/end") Then
+ eFile.Close
+ End If
+Loop
+iFile.Close
+
+
+Text = MsgBox("Conversion complete!", 0, "csvtolatex " + version) \ No newline at end of file