U-SQL An output statement must have at least one local run error - u-sql

i m trying to play little bit with U-SQL. I want to run script locally but i m getting this error: "An output statement must have at least one local run error". I put my input file in data root directory and i just want to extract one column to the new file. Simple script just to see how it works.
Did i miss some step here?

U-SQL scripts can either do DDL operations like CREATE TABLE or data output operations, in which case they must have an OUTPUT statement, something like this:
// Output results
OUTPUT #output
TO "/output/output.csv"
USING Outputters.Csv();

Related

Mongolite Showing No Data After Connecting to MongoDB

I'm pretty novice with Mongolite, and I'm trying to query my database which is server side. However, I'm running into an issue that all of my queries are returning no data.
To connect, I run the following code:
con <- mongo(db="terrain", url="mongodb://22.92.59.149:27017")
After that, I run the following code, and get this output:
con$count('{}')
0
con$find('{}')
data frame with 0 columns and 0 rows
When I export the database from the command line as a csv, it exports the exact same file that was imported via command line, so as far as I can tell it is on my end. Additionally, I believe I am looking in the correct location because when I listCollections, I get a list of all of the databases:
admin <- mongo(db="admin", url="mongodb://22.92.59.149:27017")
admin$run('{"listDatabases":1}')
This segment of code outputs a list of all of the databases, their size on the disc, and whether they are empty or not. This is the same result if you query the DB names from the command line.
What am I missing here? I'm sure its something very simple.
Thanks in advance!

Saving the output of the function

I have a very complex function. It takes 5 days to give me
me the output. Sometime, after I get the result, I need to shut down my computer. Then, when I would like to extract some values (output) of my function, I need to rerun the function again and wait for 5 days again.
Is there a way that I can comeback to the result of my function at any time even when I quit R? How can I come back to the result of my function without re-running it again?
There are a couple of options. First, assuming that you set a variable equal to the function output you could use save.image() with a .RData ending and this could save global environment variables. You could then load this .RData file the the next time and you want to see the output. Another possibility is to use write.table() or a similar function to save a .txt or .csv file if your output is a matrix or vector. You could then load this output in another session.
You can store your output to a file by using sink function in R studio
The sink function can force all output to a file
Redirecting output to a file include 3 steps:
Redirect output to a file name output.file
sink("output.txt")
Run the script to capture its output, where script.R is the name of the script file containing the program
source("script.R")
Resume writing output to console
sink()
That's it now your program's output has been saved in a file

R: If (file.exists(

I am just learning R, so this might be a simple question.
I have a bunch of code that I want to run IF a certain file path that was generated earlier in the code exists. So...
1.A path is created
2.If the path exists, then the rest of the code should run
This is what this portion of the code looks like:
label_file=paste(label_folder,"Files/",as.matrix(babble_data)[n,3],label_extension,sep="")
if (file.exists(label_file){...
It is running without giving me any errors, but it is treating EVERY file path (even the ones that DO exist) like the don't exist.
Is my syntax incorrect? All the examples I can find look like this, so I have no idea why it isn't working as it is supposed to. Any idea? Thanks.
You are missing a closing round bracket in the if statement before the curly bracket. This can have all possible side effects, although a code parsing error is the most probable one.
Additionally, as.matrix(babble_data)[n,3] can produce a vector of results, so paste can produce a vector of filenames and if (file.exists( would fail.

in R , how to get the output to a file as well as on console at the same time?

I want only the output not the commands, and I want to see the output on the console at the same time.
I tried sink and capture.output , but tried to work through the examples but I can accomplish only one of the task i.e. either to console or to a file.
I am new to R, and was thinking whether there is a function that can help me see the output on the console and save it to a text file as well?
Do sink(file="file.txt", split=TRUE).

How to save a function as new R script?

Given a function, how to save it to an R script (.R)?
Save works well with data, but apparently can not create .R data.
Copy pasting from the console to a new script file appears to introduce characters that cause errors.
Take a look at the dump function. That writes files that are R code that can be read back in with source or used in some other way.
I have to ask: why are you writing your functions in the console in the first place? Any number of editors support a "source" call, so you can update the function as you edit. Copy/pasting from the console will carry prompt characters along , if nothing else, so it's a bad idea to begin with.

Resources