Writing JSON to an output file using tool sstable2json in Cassandra - cassandra

I want to export the SSTables to JSON. So I am using sstable2json.bat. I am able to run this bat using command prompt and can see the JSON result printing on command prompt itself. I used the following command:
sstable2json H:/cassandra/db/data/191/191/191-191-hd-1-Data.db
I have to write this JSON content to an output file. For that I used the following command:
sstable2json -f H:/output.json H:/cassandra/db/data/191/191/191-191-hd-1-Data.db
But this command is showing me exception like:
You must supply exactly one sstable
Usage: org.apache.cassandra.tools.SSTableExport<sstable> [-k key [-k key [...]]
-x key [-x key [...]]]
Can any one correct my mistake if any. I am using Cassandra 1.1.2 version.

Just redirect stdout to a file. You can find the documentation for redirection here: http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/redirection.mspx?mfr=true
For example:
sstable2json H:/cassandra/db/data/191/191/191-191-hd-1-Data.db>mysstable.json
The contents will then be in a file named mysstable.json.

Related

openSMILE: Trying to Extract emotion features from emobase.conf results in error

I was going through the openSMILE book and in section 2.5.6, it mentioned that in order to extract emotion features, one needs to run a command of this sort:
SMILExtract_Release -C config/emobase.conf -I input.wav -O angers.arff -instname ANGER -classes {anger,fear,disgust} -classlabel anger
However, running this command gives an error:
(ERROR) [0] in commandlineParser : doParse: unknown option '-instname' on commandline!
Wanted to know how to fix this. Is -instname a deprecated option? If so, what should it be replaced with?
This is happening because config/emobase.conf doesn't have a definition for instname in the arrfsink component.
openSMILE allows to define new command line options for the openSMILE binary directly in the configuration file. If you want to define this parameter your config file must have a line like this:
instanceName=\cm[instname(N){unknown}:instance name]
You can run opensmile-2.3.0/SMILExtract -h to see which CMD options are available regardless of the configuration file. Other CMD parameters such as -instname should be defined in the configfile. Please check "config\shared\standard_data_output.conf.inc" for an example o how to define this command line option for your configuration file.

Converting pcapng file into csv file

I'm using Ubuntu terminal and I'm running using
tshark -r file.pcapng -T fields -e 6lowpan.src -e frame.proto >file.csv
I also can't get protocol info. I want to convert a .pcapng file into a .csv file.
But, I'm not able to retrieve 6 lowpan source address using 6lowpan.src. In the csv file i am getting empty file without any output and also I want the output data in text format.

Register a variable output with Ansible CLI / Ad-Hoc

Can I register the output of a task? Is there an argument with ansible command for that ?
This is my command:
ansible all -m ios_command -a"commands='show run'" -i Resources/Inventory/hosts
I need this, because the output is a dictionary and I only need the value for one key. If this is not possible, is there a way to save the value of that key to a file?
I have found that you can convert ansible output to json when executing playbooks with "ANSIBLE_STDOUT_CALLBACK=json" preceding the "ansible-playbook" command. Example:
ANSIBLE_STDOUT_CALLBACK=json ansible-playbook Resources/.Scripts/.Users.yml
This will give you a large output because it also shows each host's facts, but will have a key for each host on each task.
This method is not possible with ansible command, but it's output is similar to json. It just shows "10.20.30.111 | SUCCESS =>" before the main bracket.
Source
Set the following in your ansible.cfg under the [defaults] group
bin_ansible_callbacks=True
Then as #D_Esc mentioned, you can use
ANSIBLE_STDOUT_CALLBACK=json ansible all -m ios_command -a"commands='show run'" -i Resources/Inventory/hosts
and can get the json output which you can try to parse.
I have not found a way to register the output to a variable using ad-hoc commands

cassandra copy [Errno 13] Permission denied

Cassandra newbie here. I have just set up a proof of concept single node machine on Red Hat Linux. I finally got all of the permissions correct and started up the machine. I then created a keyspace called harvard, issues the use command to switch into harvard, and then created a table called hmxpc.
I then wanted to import a .csv file. I placed the .csv file in the cassandra folder just for simplicity, chmod 755 the file, and issued the following:
copy hmxpc (course_id, userid_di, certified, explored, final_cc_cname_di, gender, grade, incomplete_flag, last_event_di, loe_di, nchapters, ndays_act, nevents, nforum_posts, nplay_video, registered, roles, start_time_di, viewed, yob) from 'cassandra/HMXPC.csv' with header=true;
When I run it, I get the following error:
[Errno 13] Permission denied: 'import_harvard_hmxpc.err'
What am I doing wrong?
I just had the same issue. I figured it out by using the --debug flag.
My floats had ',' instead of '.' so my csv couldn't be parsed. CQLSH tried to write an err file describing the issue, but I was in /root, which cassandra can't write to. So I cd'ed to /tmp and did the same, this time getting I got errors showing that my floats couldn't be parsed
The problem ended up being a Red Hat permissions issue and had nothing to do with Cassandra. Thanks for looking.
I was getting the same error as show in screenshot_Errored. Moved the .csv file to .cassandra directory and was able to execute the same csql command as shown in screenshot_worked
Beyond the other cases that are described in other responses, the error may appear, as described below if an incorrect ordering or number of columns appears in the COPY command.
i.e consider having a CSV file with the following header line:
actor, added date, video id, character name, description, encoding, tags, title, user id
If I use the following COPY command:
cqlsh:killrvideo> COPY videos_by_actor(actor, added_date, character_name, description, encoding, tags, title, user_id, video_id) FROM 'videos_by_actor.csv' WITH HEADER = true;
I will get the Error 13:
Using 7 child processes
Starting copy of killrvideo.videos_by_actor with columns [actor, added_date, character_name, description, encoding, tags, title, user_id, video_id].
[Errno 13] Permission denied: 'import_killrvideo_videos_by_actor.err'
If I set the names of the columns correctly in the COPY commands as follows
cqlsh:killrvideo>COPY videos_by_actor(actor, added_date, video_id, character_name, description, encoding, tags, title, user_id ) FROM 'videos_by_actor.csv' WITH HEADER = true
then command completes successfully.
Using 7 child processes
Starting copy of killrvideo.videos_by_actor with columns [actor, added_date, video_id, character_name, description, encoding, tags, title, user_id].
Processed: 81659 rows; Rate: 5149 rows/s; Avg. rate: 2520 rows/s
81659 rows imported from 1 files in 32.399 seconds (0 skipped).
Here's my checklist for this rather non-specific (catch-all) cqlsh error "[Errno 13] Permission denied" for the containerized use cases (e.g. when using bitnami/cassandra:latest):
Make sure the path you are supplying to the COPY command is the internal (container) path, not an external one (host, PVC etc).
Make sure the CSV file has correct read permissions for the internal container user ID, not the external one (host, PVC etc), especially if the CSV was created in another containerized app (e.g. Jupyter Notebook).
If the file contains a header, our COPY command ends in WITH HEADER = true; (yes, omitting it also raises permission denied error...)
For example, assuming you have run your Cassandra container like this:
$ docker run -d --rm --name cassandra -v /tmp:/bitnami -u 1001 bitnami/cassandra:4.0
Then the COPY command issued in cqlsh to import a /tmp/random_data1.csv from the host should be:
> COPY dicts.dict1 (key, value) FROM '/bitnami/random_data1.csv' WITH HEADER = true;
and the /tmp/random_data1.csv file should be owned by user 1001 or accessible for reading for all users.
The most bizarre reason for this error is lack of write access... to the errors file (the path to which is left empty in the default config file). This is particularly likely if running Cassandra (container) as a non-root user.
To solve it, one needs to pass a custom config file (e.g. /bitnami/cqlshrc) when executing the client:
$ cqlsh -u <user> -p <pass> --cqlshrc=/bitnami/cqlshrc
There should be a sample config cqlshrc.sample shipped with your installation (use cd / && find | grep cqlshrc to find it).
Changes to be made in your custom config file:
# uncomment this section:
; [copy-from] -> [copy-from]
# uncomment and specify custom error file
; errfile = -> errfile = /bitnami/cassandra-errfile.txt
More info on the setting in question: errfile.

D2RQ parameters for generate-mapping

We are currently working on a project involving an "ordinary" relational database, but we wish to enable SPARQL requests towards this database.
d2rq.org is a tool that enables SPARQL to be run towards the database with the help of a .ttl file which defines the database to RDF mapping.
This .ttl file can be built automatically with a D2RQ tool named "generate-mapping".
http://d2rq.org/generate-mapping takes quite a few arguments, some preceeded with a single dash "-" and some double "--". My challenge is that any argument preceeded with a double dash generates this error:
Command:
./generate-mapping -u root -p password -o testmappingLocal.ttl --verbose jdbc:mysql:///iswc
Result:
Exception in thread "main" java.lang.IllegalArgumentException: Unknown argument: --verbose
at jena.cmdline.CommandLine.handleUnrecognizedArg(CommandLine.java:215)
at jena.cmdline.CommandLine.process(CommandLine.java:177)
at d2rq.generate_mapping.main(generate_mapping.java:41)
Any help with the double-dash arguments will be greatly appreciated.
OS: Ubuntu Linux, D2RQ version: 0.8
D2rq and mysql database using generate mapping file & rdf files.
1).mapping file generate commands:
./generate-mapping -u root -p root -o /home/bigtapp/Documents/d2rqgenerate_mapping/mapfile.ttl jdbc:mysql://localhost:3306/d2rq
note: 1. root -p root -> mysql db username & password.
2. /home/bigtapp/Documents/d2rqgenerate_mapping/mapfile.ttl -> file save output path .
3.jdbc:mysql://localhost:3306 ->mysql driver.
4./d2rq ->database name.
2).the mapping file using RDF creation:
use following command.
The RDF syntax to use for output. Supported syntaxes are “TURTLE”, “RDF/XML”, “RDF/XML-ABBREV”, “N3”, and “N-TRIPLE” (the default). “N-TRIPLE” works best for large databases.
command:
./dump-rdf -f RDF/XML -b localhost:3306 -o /home/bigtapp/Documents/d2rqgenerate_mapping/dumpfile.rdf /home/bigtapp/Documents/d2rqgenerate_mapping/mapfile.ttl.
apache-jena-fuseki create dataset then rdf file uploadserver then your using sparql query ..you get the result...

Resources