CSV to Excel [xlsx] script - excel

In excel I can open up a csv file using external data sources, and then chose to get data from text. This takes me through a set of steps to import the file. This works great, but I have a need to automate this process as many of these documents will need to be converted over time.
Is there a way to run a similar process as a script? I'm a complete newbie in this space.

You can run this command in a script:
csv2odf yourdata.csv yourtemplate.xlsx output.xlsx
You would need to get csv2odf and Python and create a template like this:
Insert column titles with the same number of columns as the csv.
Add one sample row of data. You can add formatting if you want.
Save the template as xlsx.

Related

Open text file using pandas in python

I´m struggling to open a text file using pandas.
I have this dataset from an experiment and it should be a 87x249 table.
However, when I use the pandas df.read_csv() command I get all the time a table which is 87x1. I tried to change the delimiters but I always get different tables of 87x1.
I tried to open the ascii file in excel and then save it as a csv. Then it worked and I got a nice table. But the point for me is to use the txt file directly.

Kettle (spoon) - get filename for excel output from field in the excel field in input

I'm trying to process an excel , I need to generate una excel file for each row and as filename I need to use one of the fields in the row.
The excel output hasn't the option "Accept filename from field" and I can't figure out how to achieve it.
thanks
You need to copy the rows into memory and then loop it across the excel file to generate multiple files. You need to break your solution to 2 parts. First of all, read all the rows from Excel Input step into "Copy rows to Result" step as a variable. In the next transformation, use the same variable to use it as a file parameter.
Please check the two links:
SO Similar Question: Pentaho : How to split single Excel file to multiple excel sheet output
Blog : https://anotherreeshu.wordpress.com/2014/12/23/using-copy-rows-to-result-in-pentaho-data-integration/
Hope this helps :)
The issue is that the step is mostly made for outputting the rows to a single file, not making a file for each row.
This isn't the most elegant solution but I do think it will work. From your transformation you can call a sub-transformation (Mapping) and send a variable to it containing the filename. The sub-transformation can simply do one thing: write the file, and it should work fine. Make sense?

How to copy an excel sheet to a text container

I do use selenium to automate the website I work. Here I have a rare scenario where a text container that represents data like a spreadsheet. So user is given with an option to copy data from spreadsheet and paste it the text container.
I would like to copy data from a sheet and paste same in the test container as a whole. So the test container displays the data in a table, as it looks in excel.
Can anyone please help me with your suggestions......
Thanks
You don't need to automate a real Excel instance (you can't anyway), or the copy/pasting process. Just write the code to directly set a fixed amount of data (e.g. read from a file) into your container, and from then you can verify that it all appears / was saved etc.
How you get the test data into your test case, so that it can get inserted into the container, depends upon the way the container works.
If it's efficient enough, you can just use POI to load the contents of an Excel file (packaged in your project alongside your test), manipulate it into whatever format the container needs, and then set it.
If it's more efficient, just extract the test data once and store it in a text file for setting into the container, if that allows you to drop POI.

Load data from excel to matlab

I'm trying to download data from excel to matlab. I downloaded data from yahoo finance. I want to load them in matlab however it's not successful. Right down here you have my codes and the message matlab is sending to me. Can somebody help me to improve my codes?
load SP100Duan.csv
Error using load
Number of columns on line 18 of ASCII file C:\Users\11202931\Desktop\SP100Duan.csv
must be the same as previous lines.
There are a TON of ways to get data into MATLAB. Generally speaking, mixed text/numbers gives MATLAB problems. You may want to clean up the excel file so there is no text in columns that should be numbers. Some possible methods to load data:
Use readtable function. Eg. mytable = readtable('mycsvfile.csv') All your data is put a table datatype, which I personally find convenient.
You can read data directly from an excel file using xlsread function. From your description, it sounds like your datatype is a .csv file though.
Use csvread function.
You can often copy and paste data in excel directly into a variable in Matlab. eg. (i) type: x = 0, then (ii) double click on x variable in your workspace, then (iii) copy data from excel and paste into your x variable (iv) execute something like save mydata.mat so you can later load it with load mydata.mat
This should be pretty simple . . .
xlsread('C:\Apple.xls', 'Sheet1', 'A1:G10')
Also, please see this link.
http://www.mathworks.com/help/matlab/ref/xlsread.html

Can I run a script in Excel that returns dbms_output instead of a query

I have a stored procedure that returns formatted, delimited text using dbms_output.put_line statements. Currently, we run the script in Toad and manually paste the output into Excel, but I was hoping I could cut out a step and get the output directly into Excel. I created a connection and set the properties to run the SP: that works fine (more or less -- the next step would have been to figure out how to supply a parameter). However, since no query is being returned, Excel doesn't recognize that there's anything to be done. Is there any way to do this automagically? Thanks.
ETA: I was just trying to figure out if I could build a cursor by inserting the GET_LINE output into it and return that, but that didn't look like it was going to work out.
If you are using Toad most recent versions (10+) allow you to save your output as an excel file. Earlier versions also allow this but with different commands.
In the output section at the bottom right click on any part of the results:
select "Export Dataset".
select your choice of export file (Excel file)
select a file path and file name
choose whatever options such as saving the sql on a separate worksheet you need
press the button in the lower right corner
Even if the output is comma delimited csv you can then have excel convert it into a real xls or xlsx format.

Resources