Is it possible to create a list in java using data from several text files

I have several text files that contain information about different programming languages โ€‹โ€‹in different countries depending on a search on Google. I have one text file for every year from 2004 to 2015. I also have a text file that splits this into each week (called iot.txt), but this file does not include the country.

Sample data from 2004.txt:

Region  java    c++ c#  python  JavaScript

Argentina   13  14  10  0   17

Australia   22  20  22  64  26

Austria 23  21  19  31  21

Belgium 20  14  17  34  25

Bolivia 25  0   0   0   0

etc.

example from iot.txt:

Week    java    c++ c#  python  JavaScript

2004-01-04 - 2004-01-10 88  23  12  8   34

2004-01-11 - 2004-01-17 88  25  12  8   36

2004-01-18 - 2004-01-24 91  24  12  8   36

2004-01-25 - 2004-01-31 88  26  11  7   36

2004-02-01 - 2004-02-07 93  26  12  7   37

My problem is that I am trying to write code that will output the number of countries that set 0 interest in python.

, . , python 2004-2015 . , - , iot.txt, , , python, , .

- ?

import java.io.BufferedReader;
import java.io.FileReader;

import java.util.*;

public class Starter{

    public static void main(String[] args) throws Exception {
        BufferedReader fh =
                new BufferedReader(new FileReader("iot.txt"));
        //First line contains the language names
        String s = fh.readLine(); 
        List<String> langs =
                new ArrayList<>(Arrays.asList(s.split("\t")));
        langs.remove(0);    //Throw away the first word - "week"
        Map<String,HashMap<String,Integer>> iot = new TreeMap<>();
        while ((s=fh.readLine())!=null)
        {
            String [] wrds = s.split("\t");
            HashMap<String,Integer> interest = new HashMap<>();
            for(int i=0;i<langs.size();i++)
                interest.put(langs.get(i), Integer.parseInt(wrds[i+1]));
            iot.put(wrds[0], interest);
        }
        fh.close();
        HashMap<Integer,HashMap<String,HashMap<String,Integer>>>
            regionsByYear = new HashMap<>();
        for (int i=2004;i<2016;i++)
        {
            BufferedReader fh1 =
                    new BufferedReader(new FileReader(i+".txt"));
            String s1 = fh1.readLine(); //Throw away the first line
            HashMap<String,HashMap<String,Integer>> year = new HashMap<>();
            while ((s1=fh1.readLine())!=null)
            {
                String [] wrds = s1.split("\t");
                HashMap<String,Integer>langMap = new HashMap<>();
                for(int j=1;j<wrds.length;j++){
                    langMap.put(langs.get(j-1), Integer.parseInt(wrds[j]));
                }
                year.put(wrds[0],langMap);
            }
            regionsByYear.put(i,year);
            fh1.close();
        }
    }
}
+4
1

Map<String, Integer> HashMap , , โ†’ 0. , python .

entrySet , e.value() e.key().

+2

Source: https://habr.com/ru/post/1616199/


All Articles