Project

General

Profile

1
package eu.dnetlib.data.collector.plugins.excel;
2

    
3
import java.util.HashMap;
4
import java.util.Iterator;
5

    
6
import eu.dnetlib.data.collector.plugins.HttpCSVCollectorPlugin;
7
import eu.dnetlib.data.collector.rmi.InterfaceDescriptor;
8
import org.junit.Assert;
9
import org.junit.Before;
10
import org.junit.Ignore;
11
import org.junit.Test;
12
/**
13
 * Created by miriam on 10/05/2017.
14
 */
15
@Ignore
16
public class ReadExcelTest {
17
	private InterfaceDescriptor descr;
18
	private Read r;
19
	private Object asserNotNul;
20

    
21
	@Before
22
	public void setUp() throws Exception {
23
		descr = new InterfaceDescriptor();
24
		descr.setBaseUrl("https://pf.fwf.ac.at/en/research-in-practice/project-finder.xlsx?&&&search%5Bcall%5D=&search%5Bdecision_board_ids%5D=&search%5Bend_date%5D=&search%5Binstitute_name%5D=&search%5Blead_firstname%5D=&search%5Blead_lastname%5D=&search%5Bper_page%5D=10&search%5Bproject_number%5D=&search%5Bproject_title%5D=&search%5Bscience_discipline_id%5D=&search%5Bstart_date%5D=&search%5Bstatus_id%5D=&search%5Bwhat%5D=&action=index&controller=projects&locale=en&per_page=10" );
25
		HashMap<String, String> params = new HashMap<String, String>();
26

    
27
		params.put("argument", "{\"replace\":{\"header\":[{\"from\":\"&\",\"to\":\"and\"}],\"body\":[{\"from\":\"\\n\",\"to\":\" \"}]}," +
28
				"\"replace_currency\":[{\"from\":\"$\",\"to\":\"€\"}],\"col_currency\":10}");
29

    
30
		params.put("argument", "{\"replace\":{\"header\":[{\"from\":\"&\",\"to\":\"and\"}],\"body\":[{\"from\":\"\\n\",\"to\":\" \"}]}," +
31
				"\"replace_currency\":[{\"from\":\"$\",\"to\":\"€\"}],\"col_currency\":10}");
32
		params.put("header_row","4");
33
		params.put("tmp_file","//tmp//fwf.xslx");
34
		params.put("remove_empty_lines","yes");
35
		params.put("remove_lines_with_id"," – ");
36
		params.put("col_id","1");
37
		params.put("remove_tmp_file","no");
38
		params.put("sheet_number","0");
39
		params.put("file_to_save","/tmp/project_search.2017.05.10.csv");
40
		params.put("separator", ",");
41
		params.put("quote","\"");
42
		descr.setParams(params);
43
//		descr.setBaseUrl("file:///tmp/gsrt_whole.xlsx");
44
//		HashMap<String, String> params = new HashMap<String, String>();
45
//
46
//		params.put("header_row","0");
47
//		params.put("tmp_file","/tmp/ERC.xslx");
48
//		params.put("remove_empty_lines","yes");
49
//		params.put("remove_lines_with_id"," – ");
50
//		params.put("col_id","2");
51
//		params.put("remove_tmp_file","no");
52
//		params.put("sheet_number","0");
53
//		params.put("file_to_save","/tmp/ERC.csv");
54
//		params.put("separator", ",");
55
//		params.put("quote","\"");
56
//		descr.setParams(params);
57
//		r = new Read(descr);
58
//		r.setCollector(new HttpCSVCollectorPlugin());
59
	}
60

    
61
	@Test
62
	@Ignore
63
	public void readExcelFromUrl()throws Exception{
64
		Iterator<String> it = r.parseFile().iterator();
65
		int i = 0;
66
		String st = null;
67
		try {
68
			while (it.hasNext()) {
69
				st = it.next();
70
				Assert.assertNotNull(st);
71
				i++;
72
				//System.out.println(it.next());
73
			}
74
		}catch(Exception e){
75
			System.out.println("linea " + i);
76
			e.printStackTrace();
77
			System.out.println(st);
78
		}
79

    
80
	}
81

    
82
//	@Test
83
//	public void readExcelFromFile() throws Exception{
84
//		Iterator<String> it = r.parseFile().iterator();
85
//		int i =1;
86
//		String st = null;
87
//		try {
88
//			while (it.hasNext()) {
89
//				st = it.next();
90
//				Assert.assertNotNull(st);
91
//				i++;
92
//				//System.out.println(it.next());
93
//			}
94
//		}catch(Exception e){
95
//			System.out.println("linea " + i);
96
//			e.printStackTrace();
97
//			System.out.println(st);
98
//		}
99
//
100
//
101
//	}
102
}
    (1-1/1)