I have the following doubt, is there a way to modify the files I downloaded with a session?
For example, I want to add a row to an Excel file but this has to be made at the time the file is downloaded.
Thaks.
Thanks for your support.
The thing is that I want to edit a CSV file but I can´t manage to make my script work correctly, I want to replace a value on the csv but I don´t have the exact code line to do it. Any idea of how this could be done?
Thanks.
I haven't a way to edit a doc that way. You could download it with screen-scraper, and use a 3rd party tool to edit it and move to another location, but I don't have a way to do it on the fly.
Also it can´t be done once the file is downloaded? I mean, if I already have the file I can´t edit it with Screen scraper with some instructions on a script?
I read some information and found this: http://community.screen-scraper.com/script_repository/Input_from_CSV but this only works for reading files? I can´t add information to a CSV with this?
Thank you.
A CSV is very easy to edit because it's a standard. If you want to edit a MS Excel files, they are proprietary, and I don't have a library built in to do it, but it can be done. POI if free to use, and if you import the jar to screen-scraper you can call it and use it within the scrape.
Thanks for your support.
The thing is that I want to edit a CSV file but I can´t manage to make my script work correctly, I want to replace a value on the csv but I don´t have the exact code line to do it. Any idea of how this could be done?
Thanks.
How to edit a CSV
Thanks for your support.
The thing is that I want to edit a CSV file but I can´t manage to make my script work correctly, I want to replace a value on the csv but I don´t have the exact code line to do it. Any idea of how this could be done?
Thanks.
I haven't a way to edit a doc
I haven't a way to edit a doc that way. You could download it with screen-scraper, and use a 3rd party tool to edit it and move to another location, but I don't have a way to do it on the fly.
After being downloaded?
Also it can´t be done once the file is downloaded? I mean, if I already have the file I can´t edit it with Screen scraper with some instructions on a script?
I read some information and found this: http://community.screen-scraper.com/script_repository/Input_from_CSV but this only works for reading files? I can´t add information to a CSV with this?
Thank you.
A CSV is very easy to edit
A CSV is very easy to edit because it's a standard. If you want to edit a MS Excel files, they are proprietary, and I don't have a library built in to do it, but it can be done. POI if free to use, and if you import the jar to screen-scraper you can call it and use it within the scrape.
How to edit a CSV
Thanks for your support.
The thing is that I want to edit a CSV file but I can´t manage to make my script work correctly, I want to replace a value on the csv but I don´t have the exact code line to do it. Any idea of how this could be done?
Thanks.
Once you download the file,
Once you download the file, read it in line by line, edit the column, and save to a new file.
import au.com.bytecode.opencsv.*;
// Set input file
fileNameIn = "output/tmp_file.csv";
session.log("~~~Reading input from: " + fileNameIn);
File inputFile = new File(fileNameIn);
// Set output file
CsvWriter writer = new CsvWriter("output/new_file.csv", false);
// Read input
CSVReader reader = new CSVReader(new FileReader(inputFile));
String[] oldLine;
line = 0;
while ((oldLine = reader.readNext())!=null)
{
// oldLine is an array of values from the line
if (line>0)
{
// Replace column 2
oldLine[2] = "Changed";
}
line++;
writer.write(oldLine);
writer.flush();
}
writer.close();
Thanks
Thanks a lot for your support. I managed to do it in some other way but this code helped me.