Transfer text file to csv format Java [closed] - java

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I have a "|" separated data file. Need to transfer it to csv format.
In csv I have 9 columns. And the data is in format:
257|30|1666|4906|3712|1|1.00|4.99|1.04|2|27.28|2.00|4.92|1|4.99|1.00|1.04|9|0.222222|0.000000|0.111111|-1.000000
254|1|1578|3713|4900|1|1.00|1.99|1.26|16|53.30|25.00|12.23|39|125.30|55.00|62.48|320|0.050000|0.000000|0.003125|0.000000
256|38|227|25303|25306|1|1.00|11.99|1.99|1|6.99|1.00|1.67|7|62.28|9.00|9.08|16|0.062500|1.000000|0.062500|0.000000
is there a built functions? What do you advise to use?
Thanks

If you use an inputstream to read from your data file and replace every occurrence of the pipe symbol with a comma and you use an output stream to write back you will be a happy man. you can use every 9th pipe as some sort signal to move your output to a new line. That's like 10 lines of code

Related

Parse a pdf containing tabular data and obtain a list of key value pairs in java? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 days ago.
Improve this question
I want to parse a pdf which is having a table. But, couldn't find any library(in java) which could read a pdf in a format in which it appears.
Basically, the existing libraries read a table just as a string without preserving the format. So, what is the best way to parse it and get the list of key value pairs in java?
Pdf screenshot sample

Is there a Java XML parsing API that preserves numeric character references? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Say I have the following bits of XML:
<string>&</string>
<string>&</string>
Is there a Java XML parsing API that will preserve them as is when reading them?
I've explored SAX, DOM, and am currently on StAX. They all convert the references before they feed me the character data.
Thanks!
To the best of my knowledge the answer is no (though proving the non-existence of a piece of software is difficult).
If this is really a requirement (and I'm sceptical), then I would suggest preprocessing the input to replace &# by, say, §#, perhaps choosing § from the Unicode private use area if you want to be ultra-cautious.

CSV with JSON columns [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I'm intending to have few of my columns in my dataset to be in JSON format, for grouping purposes, but the general CSV format is preserved (or whatever delimiter).
Is there a Java library that can process, parse, read, write CSVs that has columns as JSON?
I don't know of any library that can do this. However, it is simple enough to use your go to CSV library, e.g. Commons CSV and run the value string through Jackson or Gson.
However, I would recommend using JSON lines as a substitute for CSV. This can be parsed nicely out of the box with Jackson or Gson. You would end up with CSV like files like this:
["Name", "Session", "Score", "Completed", "some object"]
["Gilbert", "2013", 24, true, {"foo": "bar"}]

How to create Data file for storing input data such as employee info [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
guys i saw these couple of codes while i was browsing on the net. when i read the the whole content it says that these codes are for creating a data file for storing an inputs such as Employee information or registered accounts etc. can anyone please give me an example for this?
backupRecords();
outputstream = new DataOutputStream(new FileOutputStream("data.dat"));
reWriteRecords(outputstream);
inputstream = new DataInputStream(new FileOutputStream("temp.dat"));
I am writing this answer assuming that you wanted to know hot the contents of the input file look like.
The easy answer would be something like this:
data.txt:
Yuri;Gagarin;Russia;52;Male
Booch;Gary;USA;40;Male
Randy;Orton;USA;52;Male
Anna;Tereshkova;Russia;40;Female
Maria;Sharapova;Russia;32;Female
Notice the delimiter ';'. The java code after opening the file for reading, reads the contents of the file and would be written under the assumption that each occurrence of the delimiter ';' gives a piece of information. For example, FirstName or LastName or Country or Age or Gender.
The better solution for reading data is xml.
data.xml:
<PersonInfo>
<FirstName>Yuri</FirstName>
<LastName>Gagarin</LastName>
<Country>Russia</Country>
<Age>52</Age>
<Gender>Male</Gender>
....
</PersonInfo>

Update a data in SQL database [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I have a table in my database. I am using jdbc to use this database. I want to update a particular data by subtracting it to some value.
Suppose a student with name xyz is there. Currently his marks in a subject is 50. I want to delete it by 10, then what would be the syntax? I am new to SQL.
More or less:
update students
set mark = mark - 10
where name = 'xyz'
Can't give a better answer than that, as your question is very limited in useful and concrete information. I'm sure you'll figure it out.

Categories