Is it possible to create a Java program which recognizes the text in a .txt file and write it in a .csv file? If yes,how would you start with such a problem?
My .txt
try this may help
public class Test {
public static void main(String[] args) throws URISyntaxException,
IOException {
FileWriter writer = null;
File file = new File("d:/sample.txt");
Scanner scan = new Scanner(file);
File file2 = new File("d:/CSV.csv");
file.createNewFile();
writer = new FileWriter(file2);
while (scan.hasNext()) {
String csv = scan.nextLine().replace("|", ",");
System.out.println(csv);
writer.append(csv);
writer.append("\n");
writer.flush();
}
}
}
sample.txt:-
He|looked|for|a|book.
He|picked|up|the|book.