Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
markp201
Creator III
Creator III

Removing headers from csv

I've seen a few various ideas but we required one which removed the headers from a table in the load script.

Normally, this would be an ETL process but Qlikview sufficed

We loaded the table, saved to a csv and called the macro

Table:

SELECT

  *

FROM

  table

;

STORE Table INTO [...].csv (txt, delimiter is '|');

DROP TABLE Table;

LET vx = RemoveHeaders();

Below is the macro.

Function RemoveHeaders()

SET objFSO = CreateObject("Scripting.FileSystemObject")

text = ""

Lines = 0

SET objCSVFile = objFSO.OpenTextFile("C:\users\....csv",1)

objCSVFile.ReadLine

DO WHILE NOT objCSVFile.AtEndOfStream

  text = text & objCSVFile.ReadLine & vbCrLf

  Lines = Lines + 1

LOOP

objCSVFile.Close

SET objResultFile = objFSO.CreateTextFile("c:\users\...csv",true)

objResultFile.WriteLine "Report name,Date (need function)"

objResultFile.Write text

objResultFile.Write Lines

objResultFile.Close

End Function

Nice feature is this will work for any number of columns.

2 Replies
markp201
Creator III
Creator III
Author

Qlikview 11 let us down.  Using macros on the server requires the IE Plugin.

We're investigating a windows scheduled task to open the document, reload and run the macro.

miikkaqlick
Partner - Creator II
Partner - Creator II

Hi!

I had almost same problem but with xml-files. Here's part of my script:

EXECUTE cmd.exe /c more +1 "$(vStore)test.xml" > "$(vStore)$(vCopiedFile)";

I have loop that checks one folder and removes some lines from all files that haven't been handled.

More command with +1 drops one line from file start away. You could make this part of some transform layer and end application would load only modified files.

You have to allow execute statement for file.

Br,

Miikka

Climber Finland