I am new to Auto It and I want to copy the contents of a file(any type) to another by creating a word document on the hard drive using Auto It script.
Could anyone help me please?
Note: I want to open a file, read the contents and write them to another file by creating it in any specified location as per my wish.
Please help me in this aspect
Thanks in adv
;$sourceFile="c:\source.file"
;$destFile="c:\dest.file"
; Open source file, file must exist
$sourceFile=FileOpenDialog("Source file", "c:\", "All(*.*)", 1)
If #error Then
MsgBox("No file choosen")
Exit
EndIf
; Open dest file
$destFile=FileOpenDialog("Destination file", "c:\", "All(*.*)")
If #error Then
MsgBox("No file choosen")
Exit
EndIf
$result=FileCopy($sourceFile, $destFile)
If ($result = 0) Then
MsgBox("copy failed")
EndIf
A file does not contain what you see on the screen if you open it. It does, but it's not a 1:1 copy.
Open any .docx or .zip file with a text editor (like notepad). You won't see your written text or files/folders in there, only things like "ÐÏࡱá". Unreadable to humans. The data in the file is different from what a program like Word or WinZip shows you is in a file. There are a couple of reasons for this.
A file needs to be easy for computers to read and edit (not humans). It is formatted in a certain way that makes it easy for a programmer to parse. (Parsing is how a computer reads a file -- but this is oversimplified.) The file as you see it after opening in a program is easy for humans to read and edit.
So reading from any file in the sense of this is not going to work:
Read out the file
Put the contents in clipboard (Ctrl+C idea)
Paste in Word (Ctrl+V idea)
because you're going to end up with a bunch of unreadable (to humans) nonsense. So then the question: How DO you do it?
You pick a number of formats you want to read out from: docx, doc, xls, pdf. Not simply "anything ever invented and ever will be". You find a converter for each of the formats, or even write one if you think you can do that, and a writer for your output format (docx).
In terms of a "simple project that can convert anything to docx"... You're screwed. It's complicated!
Related
Lately I'm having a strange problem with RStudio (v1.3.1056 on Ubuntu 18.04): When I try to open some text files, RStudio refuses with the message file is binary rather than text:
Yet, the file I'm trying to open is definitely a text file. As an example, take this bibtex file:
#misc{test,
author = {test},
year = {2018},
title = {test},
}
When I try to open it with the file name "test.bib", I get the error above. When renaming it to "test.txt" RStudio opens it without complaining. Here the steps as R code:
rstudioapi::navigateToFile("test.bib") # won't work
file.copy("test.bib", "test.txt", overwrite = TRUE)
rstudioapi::navigateToFile("test.txt") # works perfectly
I'm pretty sure that RStudio wouldn't mind the file ending and just try to open files as text no matter what in the past. But now I either have to rename the file or get a different text editor to edit my bib and other files.
As far as I can tell, this is not a problem of Ubuntu marking the file as binary. Otherwise one of these commands would complain, I think:
readLines("test.bib")
system("grep 'misc' test.bib")
The solution to this problem is rather stupid. Apparently it is possible in Linux to include newline characters in your folder name, yet either RStudio or file doesn't like that. I had no idea that my test.bib file was sitting in a folder with a newline character. So the problem can be reproduced with:
bib <- "#misc{test,
author = {test},
year = {2018},
title = {test},
}"
dir.create("test\nfolder")
writeLines(bib, "./test\nfolder/test.bib")
rstudioapi::navigateToFile("./test\nfolder/test.bib") # throws error
While it works when the folder is just called "test folder"! Sorry for wasting people's time, I should have just tested it elsewhere...
You can see the current test of whether a file is text or not here: https://github.com/rstudio/rstudio/blob/d1289249b11e0d12d2be12b3ceb701c41f110cec/src/cpp/session/SessionModuleContext.cpp#L1216. It looks for a recorded MIME type according to the filename extension (and .bib isn't in the list currently, so that will fail).
It then tries to run
file --dereference --mime --brief test.bib
and looks at the result. Maybe your system doesn't recognize test.bib as text/plain? A few other types would also be recognized as text; see the end of that function on github.
I used in R
download.file('https://www.census.gov/retail/marts/www/marts_current.xls', method='auto',
destfile='C:/Users/<my name>/Desktop/test.xls')
expecting to see the contents of marts_current.xls in test.xls but much of the content in the source file is left out.
Can someone help me understand why? How can I get the whole file?
Excel xls files are binary files and care should be taken to download them as such. the default for download.files is to assume they are text files. You can control this with the mode= flag. Use
download.file('https://www.census.gov/retail/marts/www/marts_current.xls', method='auto',
destfile='C:/Users/<my name>/Desktop/test.xls', mode="wb")
I want to open a .jl file and convert it to a readable file preferably in .xls format.
I do not have any any idea about Julia language.
Is there a file opener for jl files?
I came here with the same question, but since the file I was looking at was clearly JSON data, I did some more searching.
The .jl file extension also refers to JSON lines, sometimes instead a .jsonl extension.
More here: http://jsonlines.org/
You can search for .json to Excel to find a converter, e.g. https://json-csv.com/ (this worked fine on my JSON lines file).
A .jl file is a julia script.
It is source code.
Not data.
You can open it up in any text editor, e.g. notepad on windows.
However, it won't normally contain anything useful to you unless you want to edit that code.
(It might contain some array literals that you want, I guess)
Perhaps you mean to ask "How can I open a .jld file"?
Which is a julia HDF5 file.
In which case please ask another question.
As I see, Julia is a script language therefor the file can be opened in a text editor like Notepad++, Vim, etc. Do not use word processor (like LibreOffice Writer) if you want to modify it, but it's OK if you want to read only.
To get started:
https://docs.julialang.org/en/stable/
more a tip question that can save lots of time in many cases. I have a script.R file which I try to save and get the error:
Not all of the characters in ~/folder/script.R could be encoded using ASCII. To save using a different encoding, choose "File | Save with Encoding..." from the main menu.
I was working on this file for months and today I was editing like crazy my code and got this error for the first time, so obviously I inserted a character that can not be encoded while I was working today.
My question is, can I track and find this specific character and where exactly in the document is?
There are about 1000 lines in my code and it's almost impossible to manually search it.
Use tools::showNonASCIIfile() to spot the non-ascii.
Let me suggest two slight improvements this.
Process:
Save your file using a different encoding (eg UTF-8)
set a variable 'f' to the name of that file. something like this f <- yourpath\\yourfile.R
Then use tools::showNonASCIIfile(f) to display the faulty characters.
Something to check:
I have a Markdown file which I run to output to Word document (not important).
Some of the packages I used to initialise overload previous functions. I have found that the warning messages sometimes have nonASCII characters and this seems to have caused this message for me - some fault put all that output at the end of the file and I had to delete it anyway!
Check where characters are coming back from Warnings!
Cheers
Expanding the accepted answer with this answer to another question, to check for offending characters in the script currently open in RStudio, you can use this:
tools::showNonASCIIfile(rstudioapi::getSourceEditorContext()$path)
Plain and simple: is there a way to read (not run) .sas files on osx in order to rewrite old SAS programs in another language, e.g. R? Note I do not refer to reading sas data files – I know there are several ways, I am just interested in reading old SAS code.
.sas files containing SAS code should just be a text file. You can use any text editor that you like to open and modify these files. Since the system probably doesn't have .sas files associated with any particular program you can either use the "Open with" option when "right-clicking" on the file or you could open the editor first and then open the file from within the editor.
TextEdit will work. Another editor that I like is Komodo Edit.