Read Doc file and file path from Browser - asp.net

I have an issue that I want to read a DOC file in my system but the condition is
Suppose you are working on browser and download some PDF or DOC file ,then my program should run and get the path of that file and convert that doc file in binary format.
the file download path may be change because some time it download in default folder but some times you saves that file in other locations.
my concern is this that code should execute at download time and should get file path from download history and read that file.

Related

Executable file not found

I have a python code that is taking some info from a website by selenium and then write them into a json file, after I created an '.exe' file by pyinstaller and run it I don't know where this json file is saved.
Where could be saved, should be in the initial directory?

loading downloaded data to Rstudio

mission on online course:
Download this RData file to your working directory. Then load the data into R with the following command:
load("skew.RData")
so I have downloaded it to my computer but where is my working directory? or how do I load the downloaded file to Rstudio
You can see your working directory by executing getwd().
In order to load the data you need to change it to the folder path where the data is stored.
setwd("C:/your/path")
load("skew.RData")
You can set you working directory in RStudio on the right side manually and then save the files there and open them like :
load("skew.RData")
If your file is saved somewhere else, you should define the path to it:
load("path/to/your/file/skew.RData")

What R command to use to force download files from iCloud

On a mac using iCloud file optimization, large files that are seldom used are uploaded to iCloud and only a small pointer file is left. When I look for the file in Finder, I see the file name and to the left is an icon that indicates that the file is in the cloud. To access the file, I click on the icon and the file is downloaded. With the file.exist command, R returns FALSE for the existence of the file. But after some research I found that the file link is stored in a directory below ~/Library/Mobile\ Documents/com~apple~CloudDocsand the file name is changed to xxx.icloud where xxx is the original file name.
Here's an example of the path to a a directory that holds a .icloud file from a shell in my mac
/Users/gcn/Library/Mobile Documents/com~apple~CloudDocs/Documents/workspace/nutmod/data-raw/NutrientData
I can query for the existence of the file with exists(xxx.icloud). But how do I tell my mac to download the iCloud file and then read it in? Using something like read.table or read.csv doesn't work because the pointer file is not csv.
You can read a csv file directly from a iCloud folder on the Mac by using the path to that folder. Get the path by finding it in the finder. Then right click on the filename at the bottom of the finder window where it shows all the folders leading to the file and choose: Copy "YourFile" as Pathname.
That path will look something like this:
"/Users/NAME/Library/Mobile
Documents/com~apple~CloudDoc/Docs/YourFile.csv"
Use that in your read code:
iCloudDat <- read_csv("/Users/NAME/Library/Mobile Documents/com~apple~CloudDocs/Documents/YourFileName.csv")
That should work.
If the extension isn't .txt or .csv read.table and read.csv won't work.
you have to download the file and extract the tables to a readable format.
you can download the file using download.file() which is is the utils basic library.

R code asking Excel to open a file

Here is a real world setting:
We download *.xls or *.xlsx files from the web.
We open the *.xls or *.xlsx files by double-clicking the files one by one (assuming Excel is installed) in order to eye-ball the file content.
This could become tedious (relatively speaking) if a lot of excel files were downloaded regularly, filed into different directories and need to check the file content one by one.
For example, we downloaded a file as below:
url <- "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FDATA.gov_NGAP.xlsx"
file01 <- file.path(getwd(), "NGAP.xlsx")
download.file(url, file01, mode = "wb")
What is the R code to instruct Excel to open this file? Of course we could go to download directory and double-click the file to open it. But want to instruct Excel to open the file by running R code. Thanks for any pointers provided!
The base function file.show opens files with the default application registered to handle the given file extension.
u <- "https://d396qusza40orc.cloudfront.net/getdata%2Fdata%2FDATA.gov_NGAP.xlsx"
download.file(u, f <- tempfile(fileext='.xlsx'), mode = "wb")
file.show(f)

LinqToExcel External table is not in the expected format

I've been using LinqToExcel to parse an exel document for a while and suddenly it's stoped working.
I'm getting the following error:
External table is not in the expected format.
Any ideas why this is happening? Or how to fix?
if (File.Exists(filenameFull))
{
var excel = new ExcelQueryFactory(filenameFull);
IList<Row> scanningRangesRows =
excel.Worksheet("B - Scanning Ranges").ToList();
I was using version LinqToExcel 1.6.3, when the problem started happening I updated to the latest version LinqToExcel 1.6.6 to no avail.
I've just noticed that the file I'm downloading is significantly smaller than previous verisons. I opened it in notepad and I can see [Content_Types].xml amongst the binary data. So it appears that the data source is now being saved as an xml represention of the xls file with the same extension. When I open the same file manually in Excel it popup with
The file you are trying to open '', is in a different format
than specified by the file extension. Verify that the file is from a
trusted source before opening the file. Do you want to open the file
now?
On clicking yes the file still opens and looks the same as previous versions.
It's probably something to do with the file.
Maybe it's being saved as an .xlsx type of file. Can you try renaming the file extenstion to .xlsx and see if that works.

Resources