code: def read_data(args):
      
      filename = args['filename']
      stdin = filename == '-'
  
      if args['verbose']:
          print(f'>> Reading data from {( "stdin" if stdin else filename )}')
  
      print('')
      if args['title']:
          print('# ' + args['title'] + '\n')
  
      categories, labels, data, colors = ([] for i in range(4))
  
      f = sys.stdin if stdin else open(filename, "r")
      for line in f:
          line = line.strip()
          if line:
              if not line.startswith('#'):
                  if line.find(DELIM) > 0:
                      cols = line.split(DELIM)
                  else:
                      cols = line.split()
  
                  # Line contains categories.
                  if line.startswith('@'):
                      cols[0] = cols[0].replace("@ ", "")
                      categories = cols
  
                  # Line contains label and values.
                  else:
                      labels.append(cols[0].strip())
                      data_points = []
                      for i in range(1, len(cols)):
                          data_points.append(float(cols[i].strip()))
  
                      data.append(data_points)
      f.close()
  
      # Check that all data are valid. (i.e. There are no missing values.)
      colors = check_data(labels, data, args)
      if categories:
          # Print categories' names above the graph.
          print_categories(categories, colors)
  
      return categories, labels, data, colors
docs: Read data from a file or stdin and returns it.
  
         Filename includes (categories), labels and data.
         We append categories and labels to lists.
         Data are inserted to a list of lists due to the categories.
  
         i.e.
         labels = ['2001', '2002', '2003', ...]
         categories = ['boys', 'girls']
         data = [ [20.4, 40.5], [30.7, 100.0], ...]