I need to create a java API that takes in a CSV file and returns a JSON with some parsed data from the CSV. I've currently built a Java program in Eclipse with a bunch of static class methods that if passed in the file name of the CSV as a command-line argument to the main function, will do the parsing and create the JSON.
How do I go about modifying this code so that it will function as an API? In specific, the API should be able to accept a .csv file in the following way.
POST http://<YOUR HOST HERE>/scrub/:csv_file
Then, how do I go about returning the JSON? Thank you in advance for the help -- first time writing an API as opposed to a standard Java program.
Related
Given an arbitrary .proto file, is it possible to parse it such that I can get all the messages defined using Java?
I know that I can create the source code using protoc and use reflection to get all the info I need but I want to avoid having to compile it.
I ended up using the --descriptor_set_out then used DescriptorProtos.FileDescriptorSet to create a FileDescriptor and this allowed me to use reflection to parse the file.
I am learning to build neural nets and I came across this code on github,
https://github.com/PavelJunek/back-propagation-java
There is a training set and a validation set required to be used but I don't know where to input the files. The Readme doesn't quite explain how to use the files. How do I test with different csv files I have on this code?
How so? It tells you exactly what to do. The program needs to get two CSV files: a CSV file containing all the training data and a second CSV file containing all of the validation data.
If you have a look at the Program.java file (in the main method), you'll see that you need to pass both files as arguments with the command line.
I have created a python script for predictive analytics using pandas,numpy etc. I want to send my result set to java application . Is their simple way to do it. I found we can use Jython for java python integration but it doesn't use many data analysis libraries. Any help will be great . Thank you .
Have you tried using xml to transfer the data between the two applications ?
My next suggestion would be to output the data in JSON format in a txt file and then call the java application which will read the JSON from the text file.
Better approach here is to use java pipe input like python pythonApp.py | java read. Output of python application can be used as an input for java application till the format of data is consitent and known. Above soultions of creating a file and then reading also works but is prone to more errors.
I have some pig output files and want to read them on another machine(without hadoop installation). I just want to read a tab-seperated plain text line and parse it into a java object. I am guessing we should be able to use pig.jar as dependency and be able to read it. I could not find relevant documentation. I think this class could be used? How can we provide the schema also.
I suggest you to store data in Avro serialization format. It is Pig-independent and it allows to handle complex data structures like you described (so you don't need to write your own parser). See this article for examples.
Your pig output files are just text files, right? Then you don't need any pig or hadoop jars.
Last time i worked with Pig was on amazon's EMR platform, and the output files were stashed in an s3 bucket. They were just text files and standard java can read the file in.
That class you referenced is for reading into pig from some text format.
Are you asking for a library to parse the pig data model into java objects? I.e. the text representation of tuples & bags, etc? If so then its probably easier to write it yourself. It's a VERY simple data model with only 3 -ish datatypes..
How do I print a .dwg file from Java?
Is there is an API for accessing and passing the DWG AutoCAD file to the printer for printing?
Dwglib is a Java library for accesing DWG files. It is essentially a port from the Pythoncad DWG reading classes by Art Haas. jdwglib manages complex DWG objects allowing users to employ these objects directly in their applications.
You'll to find an API that allows you to read an AutoCAD dwg file. I haven't seen any Java ones, but you might be able to start from the .NET one following:
http://code.google.com/p/tf-net/wiki/DwgReaderWriter
Once you've found an API, then it might be as simple as printing whatever you render.