Read PDF/ Excel using Robot Framework - robotframework

How to read content in PDF/Excel using robot framework?
I tried below code to read Excel
Open Workbook ${EXECDIR}/Data/Documents/Gxp.xlsx
Sleep 5s
$ {column1} = Get cell value 1 2
I got this error
No Workbook is active
Can anyone help on this ?

did you install liblary RPA Framework ??
if you didnt install you can go to this site
this example code to see this code or you can visit the website
*** Settings ***
Documentation Read the text contained in PDF files and save it to a
... corresponding text file.
Library RPA.PDF
Library RPA.FileSystem
*** Tasks ***
Extract text from PDF files
Extract text from PDF file into a text file simple-text-example.pdf
Extract text from PDF file into a text file example-invoice.pdf
*** Keywords **
Extract text from PDF file into a text file
[Arguments] ${pdf_file_name}
${text}= Get Text From Pdf ${pdf_file_name}
Create File ${OUTPUT_DIR}${/}${pdf_file_name}.txt
FOR ${page} IN #{text.keys()}
Append To File
... ${OUTPUT_DIR}${/}${pdf_file_name}.txt
... ${text[${page}]}
END

Related

R Studio: Opening an RMD file that contains a report, and another of code, but there is no content. Am I missing a package?

I have a report sent to me in the format of an RMD file. Another RMD that contains the code. However, all that I see are empty files when opened. Im using anaconda: Rstudio 3 version 1.1.456 (is this outdated?)
Unless there is a script to open the file?
The .Rmd format is a particular flavor of markdown so you can open the file with any plain text editor to verify that it is not empty and indeed has the code inside.
I have a solution to my problem: For anyone trying to open an Rmd file in the future with similar circumstances.. open the file, while open, Go into "file - Reopen with encoding - UTF-8".

How can i convert a .xlsx (with an image on header) to PDF on Unix?

I have a .xlsx file with an image on header. When i try to convert to PDF via terminal using libreoffice it converts but the image doesn't appear on the generated PDF.
Here is a screenshot of the main .xlsx file on Excel (print mode):
And the Screenshot of the generated PDF:
The command that im using is: soffice --headless --convert-to pdf --outdir /home/output /home/input/headers_footers.xlsx
Note: To display the header image of the .xlsx on excel we need to put it into print view mode (ctrl+p)
I tested the conversion of the headers_footers.xlsx with an online convertion tool to PDF and the final result was as expected: the image appeared.
But i need to do this programatically, so im not sure if its libreoffice or if i need to use other tool, or maybe manipulate the final PDF and add an image on it?
This is not only an UNIX problem. I can reproduce the malfunction running MS Windows 10. The header image appears in print view and in manually exported PDF. But when you call
soffice --headless --convert-to pdf --outdir . sample.xlsx
on command line it won't show up. I will keep on searching for an answer but this seems to be a bug to me.
Is using a LO Basic Macro an acceptable approach for you, too?
Sub ExportCalcToPDF
sURL = convertToURL("d:\temp\lo_calc.pdf")
dim mFileType(0)
mFileType(0) = createUnoStruct("com.sun.star.beans.PropertyValue")
mFileType(0).Name = "FilterName"
mFileType(0).Value = "calc_pdf_Export"
thisComponent.storeToURL(sURL, mFileType())
End Sub
When executed this macro exports the spreadsheet to pdf. To run the macro automatically e.g. on file open assign it to "Open Document" in Tools > Customize > Events.
Doing a test by double clicking the xlsx file the image appears in the header of the pdf. However, no success from command line so far.

how to read a text file in R, having only the file's FULL PATH name ,I have as an info

I have several text file scattered in folders, sub-folders.
I have a scenario where I get a .CSV file which has one of its column as "PATH"
containing the FULL PATH name of Text file one by one under that column for example:- PATH (column1)
---------------------------------
(row)1.c:\desktop....\wd\abc.txt
(row)2.c:\desktop....\bv\qwe.txt
(row)3.c:\desktop....\qp\mno.txt
like this...
now my question is there any function in R, where I don't have to set the working directory for loading that text file, as I have said the text file are all in different location and it will be hard for me to set working dirextory every-time I want to load file one by one. any help is appreciated. :)

how to upload a text file into ipython notebook

I want a whole file as a text file instead of just a cell in IPython notebook.
I write some codes in IPython notebook and now I want to test them ,so I tried to upload some text file into IPython notebook as the raw data.But the files' extension are always ".ipynb" and the format of the text files have changed so my code can't read it correctly.
How could I upload a text file into Ipython notebook? thanks in advance
Can you be more elaborate?
Are you trying to read data out of the text file? In that case regular python open and read functions can get you the data into variables. You can even do Unix "cat" the contents of the file in a variable:
var=!cat file
Or are you trying to get the text in the ipynb files as content in an input cell so you can edit them and run them? The ipynb files are usually created by the notebook engine and they are JSON formatted. So if you just copy paste the text from them into a cell, they won't be usable as is. Use some JSON parsing to interpret their content. They are not regular python code so "%run file" wont work to get their code executed by ipython.
Elaborating the use cases may help others to give solutions...
The following lines open a text file and display the content in a jupyter notebook cell.
text_file = open(full/path/to/text/file)
file_content = text_file.read()
print(file_content)
text_file.close()
I hope this helps.
It may be late, you can do this
%%pycat full/path/to/text/file

Use of .RDA files in R CRAN package 'extRemes'

I am using the CRAN package extRemes in R.
By the command extremes.gui() the extremes toolkit opens. Now, the thing I want to do is opening one of .RDA data files that is included in the package, for example PORTw.rda. Now following the steps described in the tutorial (can be found here) something goes wrong in reading the .RDA files.
I do the following:
In the toolkit go to 'File' and then click on 'Read Data'. Select the file 'PORTw.rda' in the folder 'data' under 'extRemes'.
Select in the follwing window under the heading File Type 'R source'. Keep the boxes Heading and Delimiter empty and save the file as PORTw.
When I press the OK button it gives the following error in R:
Error in source("C:/Users/jawissie/Downloads/Documents/R/win-library/2.15/extRemes/data/PORTw.rda") :
C:/Users/jawissie/Downloads/Documents/R/win-library/2.15/extRemes/data/PORTw.rda:4:3: unexpected input
3:
4: Ý9–
Also when I try to open one of the .RDA files from the extRemes package it shows unreadable content.
Does anybody know if I am doing something wrong or if the delivered .RDA files are not correct?
(The .dat files of the same package doesn't give any problem)
I was having the same problem. The html version of the tutorial provides a link to the original .r files at; http://www.isse.ucar.edu/extremevalues/data/index.html . Just follow the link to the PORTw.R file copy and past the URL into the Read Data dialogue box and the data will be read into the workspace as originally intended.
RDA files need to be loaded with 'load'. When you "read data" you are using 'read.table'.

Resources