-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreadFile.java
56 lines (42 loc) · 1.45 KB
/
readFile.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
public class readFile {
public static void main(String[] args) {
// TODO Auto-generated method stub
//read from original file
String originalFilePath= "/Users/raveekhandagale/Documents/XML_and_WI/Data set/Douban/ratings.txt";
File originalFile = new File(originalFilePath);
String newFilePath= "/Users/raveekhandagale/Documents/XML_and_WI/Data set/Douban/parsed_ratings.txt";
File parsedRatingFile= new File(newFilePath);
try{
Scanner sc = new Scanner(originalFile);
while(sc.hasNext(""))
System.out.println(sc.next("[^\\d.]"));
//approach 1
// sc.useDelimiter("{user id:",","," movie id:","rating:");
// sc.split("{user id:",","," movie id:","rating:");
//
// int i=0;
// int userId=0;
// int movieId=0;
// double movieRating=0;
//approach 2
// while(sc.hasN()){ //compare entries from file (user_id, movie_id,rating)
// if(i%3==0)
// userId=sc.nextInt();
// if(i%3==1)
// movieId=sc.nextInt();
// if(i%3==2){
// movieRating=sc.nextDouble();
// System.out.println("For user: "+userId+"movie is"+movieId+"+movie is"+movieRating);
// }
//
// i++;
//
// }
}catch(FileNotFoundException fe){
System.out.println(fe);
}
}
}