Link to home
Start Free TrialLog in
Avatar of Luis Diaz
Luis DiazFlag for Colombia

asked on

VB Script: remove specifics lines and columns

Hello Experts,

I am looking for a VB Script which read a and remove specific lines and columns of File1.csv defined in differents Array variables and generate a File1_revised.csv:


Ex of Array Variable:
      linestoremove = Array(1,4,5)
      columnstoremove = Array(2,8,6)

Afer I launch the script File1_revised.csv will be created and shouldn't contains lines 1,4 and 5 and columns 2,6 and 8 of File1.csv.

If someone can provide the pure VbScript approacch and the CreateObject("Excel.Application") approach it would be great!

Thank you in advance for your help!
SOLUTION
Avatar of Robert Schutt
Robert Schutt
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Luis Diaz

ASKER

Thank you very much Robert! I will test it on monday as I don't have windows at home :-).
Hello Robert,

I am trying to test your first code remove1.vbs with a csv which contains ; separator and not """" between every column and I am not able to run it.
Please find attached the file which I used  for the test.

Additionally, What should I modify if the file is a xls version or a txt version?


Thank you in advance for your help.

Regards,
File1-test.csv
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello Robert,

It works!
Thank you again for your help!
Great!

Be careful by the way, the second script does not work for me with semicolon delimited input. Googling around I found that it's got something to do with localization. For me the default separator is comma and Excel is darn stubborn about letting me change that...