Skip to content

Commit bdfe7a4

Browse files
author
A. Apesteguia
committed
Fixed no args bug
1 parent fc7d291 commit bdfe7a4

File tree

4 files changed

+46
-46
lines changed

4 files changed

+46
-46
lines changed

README.md

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,30 +10,30 @@ of nodes and tree structure.
1010

1111
The fields are separated by commas in the original file
1212

13-
_(You can find it [here](examples/grades.csv))_
13+
_(You can find it [here](examples/Grades.csv))_
1414
```
15-
Last name First name SSN Test1 Test2 Test3 Test4 Final Grades
16-
Alfalfa Aloysius 123-45-6789 40.0 90.0 100.0 83.0 49.0 D-
17-
Alfred University 123-12-1234 41.0 97.0 96.0 97.0 48.0 D+
18-
Gerty Gramma 567-89-0123 41.0 80.0 60.0 40.0 44.0 C
19-
Android Electric 087-65-4321 42.0 23.0 36.0 45.0 47.0 B-
20-
Bumpkin Fred 456-78-9012 43.0 78.0 88.0 77.0 45.0 A-
21-
Rubble Betty 234-56-7890 44.0 90.0 80.0 90.0 46.0 C-
22-
Noshow Cecil 345-67-8901 45.0 11.0 -1.0 4.0 43.0 F
23-
Buff Bif 632-79-9939 46.0 20.0 30.0 40.0 50.0 B+
24-
Airpump Andrew 223-45-6789 49.0 1.0 90.0 100.0 83.0 A
25-
Backus Jim 143-12-1234 48.0 1.0 97.0 96.0 97.0 A+
26-
Carnivore Art 565-89-0123 44.0 1.0 80.0 60.0 40.0 D+
27-
Dandy Jim 087-75-4321 47.0 1.0 23.0 36.0 45.0 C+
28-
Elephant Ima 456-71-9012 45.0 1.0 78.0 88.0 77.0 B-
29-
Franklin Benny 234-56-2890 50.0 1.0 90.0 80.0 90.0 B-
30-
George Boy 345-67-3901 40.0 1.0 11.0 -1.0 4.0 B
31-
Heffalump Harvey 632-79-9439 30.0 1.0 20.0 30.0 40.0 C
15+
Last name First name SSN Test1 Test2 Test3 Test4 Final Grades
16+
Alfalfa Aloysius 123-45-6789 40.0 90.0 100.0 83.0 49.0 D-
17+
Alfred University 123-12-1234 41.0 97.0 96.0 97.0 48.0 D+
18+
Gerty Gramma 567-89-0123 41.0 80.0 60.0 40.0 44.0 C
19+
Android Electric 087-65-4321 42.0 23.0 36.0 45.0 47.0 B-
20+
Bumpkin Fred 456-78-9012 43.0 78.0 88.0 77.0 45.0 A-
21+
Rubble Betty 234-56-7890 44.0 90.0 80.0 90.0 46.0 C-
22+
Noshow Cecil 345-67-8901 45.0 11.0 -1.0 4.0 43.0 F
23+
Buff Bif 632-79-9939 46.0 20.0 30.0 40.0 50.0 B+
24+
Airpump Andrew 223-45-6789 49.0 1.0 90.0 100.0 83.0 A
25+
Backus Jim 143-12-1234 48.0 1.0 97.0 96.0 97.0 A+
26+
Carnivore Art 565-89-0123 44.0 1.0 80.0 60.0 40.0 D+
27+
Dandy Jim 087-75-4321 47.0 1.0 23.0 36.0 45.0 C+
28+
Elephant Ima 456-71-9012 45.0 1.0 78.0 88.0 77.0 B-
29+
Franklin Benny 234-56-2890 50.0 1.0 90.0 80.0 90.0 B-
30+
George Boy 345-67-3901 40.0 1.0 11.0 -1.0 4.0 B
31+
Heffalump Harvey 632-79-9439 30.0 1.0 20.0 30.0 40.0 C
3232
3333
```
3434

3535
## XML Output file
36-
_(You can find it [here](examples/gradesOutput.xml))_
36+
_(You can find it [here](examples/Grades.xml))_
3737
```
3838
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
3939
<root>
@@ -221,6 +221,7 @@ _(You can find it [here](examples/gradesOutput.xml))_
221221
## License
222222
This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details.
223223

224-
## [Donate](http://paypal.me/apesteguia)
224+
## [Donate](https://www.paypal.me/apesteguia)
225225

226226
Any amount is welcome ☕💕
227+
[PayPal](https://www.paypal.me/apesteguia)
File renamed without changes.

src/main/java/com/codepressed/CSVtoXML/Main.java

Lines changed: 24 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -7,43 +7,42 @@
77
import java.util.ArrayList;
88

99
public class Main {
10+
/**
11+
* Executes the CSV to XML conversion
12+
* @param args file input and output
13+
*
14+
*/
1015
public static void main(String[] args){
16+
//Arg validator
17+
if(args.length == 0)
18+
{
19+
System.out.println("You didn't type any args.");
20+
System.exit(0);
21+
}
22+
try {
1123

12-
/*/
13-
Vars Initialization
14-
*/
24+
//Vars Initialization
1525
String csvFile = args[0];
1626
String xmlFile = args[1];
17-
//String csvFile = "C:\\Users\\Dani\\src\\CodepressedConverter\\examples\\grades.csv";
18-
//String xmlFile = "C:\\Users\\Dani\\src\\CodepressedConverter\\examples\\gradesOutput.xml";
1927

20-
/*
21-
ArrayList of ArrayStrings Generation with CSV
22-
*/
28+
//ArrayList of ArrayStrings Generation with CSV
2329
ArrayList<String[]> elements = null;
24-
try {
2530
elements = new Reader().CSVtoArrayList(csvFile);
26-
} catch (IOException e) {
27-
System.out.println("File wasn't found, error: "+e);;
28-
}
2931

30-
/*/
31-
XML Doc Generation with ArrayList
32-
*/
32+
//XML Doc Generation with ArrayList
3333
Document xmlDoc = null;
34-
try {
3534
xmlDoc = new Util().docBuilder(elements);
36-
} catch (ParserConfigurationException e) {
37-
System.out.println("Configuration error: "+e);;
38-
}
35+
Util.transformDocToFile(xmlDoc,xmlFile);
3936

40-
/*/
41-
Transform xml DOC to a xml FILE
42-
*/
43-
try {
44-
Util.transform(xmlDoc,xmlFile);
45-
} catch (TransformerException e) {
37+
} catch (IOException e) {
38+
e.printStackTrace();
39+
System.out.println("File wasn't found, error: "+e);
40+
}
41+
catch (TransformerException e){
4642
System.out.println("Transformer error: "+e);;
4743
}
44+
catch (ParserConfigurationException e) {
45+
System.out.println("Configuration error: "+e);
46+
}
4847
}
4948
}

src/main/java/com/codepressed/CSVtoXML/Util.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Document docBuilder(ArrayList<String[]> elements) throws ParserConfigurat
7373
/*/
7474
XML Generation -> Transform DOC Data to XML Format
7575
*/
76-
public static void transform(Document xmlDoc, String xmlFile) throws TransformerException {
76+
public static void transformDocToFile(Document xmlDoc, String xmlFile) throws TransformerException {
7777
TransformerFactory xmlTransformerFactory = TransformerFactory.newInstance();
7878
Transformer xmlTransformer = xmlTransformerFactory.newTransformer();
7979
xmlTransformer.setOutputProperty(OutputKeys.INDENT, "yes");

0 commit comments

Comments
 (0)