Import/Export mlr task to file? - mlr

I'd like to export an object of class Task into a file, along with the task data associated to it. Is this possible in mlr?
Thanks!

Just using saveRDS works as expected.

Related

ArangoDB: How to export collection to CSV?

I have noticed there is a feature in web interface of ArangoDB which allows users to Download or Upload data as JSON file. However, I find nothing similar for CSV exporting. How can an existing Arango DB collection be exported to a .csv file?
If you want to export data from ArangoDB to CSV, then you should use Arangoexport. It is included in the full packages as well as the client-only packages. You find it next to the arangod server executable.
Basic usage:
https://docs.arangodb.com/3.4/Manual/Programs/Arangoexport/Examples.html#export-csv
Also see the CSV example with AQL query:
https://docs.arangodb.com/3.4/Manual/Programs/Arangoexport/Examples.html#export-via-aql-query
Using an AQL query for a CSV export allows you to transform the data if desired, e.g. to concatenate an array to a string or unpack nested objects. If you don't do that, then the JSON serialization of arrays/objects will be exported (which may or may not be what you want).
The default Arango install includes the following file:
/usr/share/arangodb3/js/contrib/CSV_export/CSVexport.js
It includes this comment:
// This is a generic CSV exporter for collections.
//
// Usage: Run with arangosh like this:
// arangosh --javascript.execute <CollName> [ <Field1> <Field2> ... ]
Unfortunately, at least in my experience, that usage tip is incorrect. Arango team, if you are reading this, please correct the file or correct my understanding.
Here's how I got it to work:
arangosh --javascript.execute "/usr/share/arangodb3/js/contrib/CSV_export/CSVexport.js" "<CollectionName>"
Please specify a password:
Then it sends the CSV data to stdout. (If you with to send it to a file, you have to deal with the password prompt in some way.)

Mass importing CSV files into PowerShell

I have a directory full of .CSV files. I'd like PowerShell to import each file and store each as a separate variable. Currently I'm relying on a while loop and having the user manually input each CSV file by hand.
However, manual input is quite tedious and time consuming for the user and I'd like to have PowerShell automate this task. What would be the best way to go about doing that? I've thought about having PowerShell generate a list via "*.csv", saving that to a variable, and then looping over said list to do the mass import. Would there be a better way to pull off this task? Thanks in advance.
I think what may be better, rather than saving each as it's own variable, would be to import the files into a hashtable where the file name is the key and the imported data is the value.
$CSVData = #{}
Get-ChildItem '.\*.csv' | ForEach{$CSVData.Add($_.Name,(Import-CSV $_.FullName))}
Then, lets say one of the files was 'MarchSales.csv' that you wanted to access. You could simply reference $CSVData['MarchSales.csv'] to work with the data. Want to work with data from each and every file? Something like this could work:
ForEach($filename in $CSVData.Keys){
Do Stuff With $CSVData[$filename]
}

SSIS FileSystem Task

I have a filesystem task I would like to move a file from 1 folder to another.
I pick up via SQL task a couple of fields to be put into variables.
I have a SourceUri, for example: http://input.mozilla.com/data/opinions.tsv.bz2
and I Have a desitination: C:\Downloaded
during another SSIS package the file is downloaded to this location
I would like to move the file from: C:\Downloaded\opinions.tsv.bz2 to C:\Archived\opinions.tsv.bz2
I can't seem to customize the task enough where I can give it the variable "http://input.mozilla.com/data/opinions.tsv.bz2" and trim it down to "opinions.tsv.bz2" and build "C:\Downloaded\opinions.tsv.bz2" and then move that to "C:\Archived\"
any help would be greatly appriciated
In that regard, using a Execute Script task is helpful as you can write C# code and make use of .NET System.IO libraries and string manipulation commands to accomplish your requirement.

Model API or load bulk data?

I want to add scrapped data to my database. I like the fact that the API enables validation but I assume that the overhead is too high. I'm writing maybe 10k rows at a time, at most. Is that accurate?
Alright, so one other issue I was having, which was preventing me from testing this hypothesis is that I'm currently unable to import my models module. I get an error message claiming that my DJANGO_SETTINGS_MODULE is undefined.
my django.wsgi script does define it and it works within the context of django. I assume that when I try to execute a python file from the command line, the .wsgi script is not run. Again, assumptions, I know.
Do I have to add my django project to my PYTHONPATH within the bashrc file to make this work?
You'll need to set your project's settings file in ~/.bashrc if you want to use it in a script.
export PYTHONPATH=$PYTHONPATH:/path/to/django/project
export DJANGO_SETTINGS_MODULE=settings
or
export DJANGO_SETTINGS_MODULE=/path/to/django/project/settings

CSVDE export file-column order wrong?

I'm using CSVDE to export data from our active directory into a CSV file, which then gets imported into a database. I'm using the -l switch to specify the columns that I'd like to export, but they don't come out in the same order consistently. Is there a workaround for this that doesn't involve opening the file in Excel? This is a nightly batch process and we'd like it to run unattended.
Thanks!
If you simply want a command-line utility that can re-order the CSV (and do much else as well), take a look at my FOSS CSV stream editor, CSVfix.
Per the docs:
LDAP can return attributes in any
order, and csvde does not attempt to
impose any order on the columns.
How about writing a python script to read reorder the csv file? You may find the python csv module useful for this.