function [ c, t ] = brc_data ( n )

%*****************************************************************************80
%
%% brc_data() generates a data file for the one billion row challenge.
%
%  Discussion:
%
%    Originally called "1brc_data" but MATLAB won't allow "1" as the
%    beginning of a function name.  Everybody has their sore spot!
%
%  Licensing:
%
%    This code is distributed under the MIT license. 
%
%  Modified:
%
%    20 October 2024
%
%  Author:
%
%    Original C version by Danny van Kooten.
%    This version by John Burkardt.
%
%  Input:
%
%    integer n: the number of observations to generate.
%
%  Output:
%
%    cell_array c(ncities): the city names.
%
%    real t(ncities): the temperatures.
%

%
%  Load the data file.
%
  filename = 'brc_data.csv';
  fprintf ( 1, '  Reading data from "%s"\n', filename );
  T = readtable ( filename );
  city_list = T{:,1};
  temp_list = T{:,2};
%
%  Figure out number of cities.
%
  ncities = length ( city_list );
  fprintf ( 1, "  Number of weather stations is %d.\n", ncities );
%
%  For each observation, choose a city "c" uniformly at random, 
%  generate a temperature measurement "t" with normal distribution
%  with variance of 10, and write it to the file.
%
  index = randi ( [ 1, ncities ], n, 1 );
  c = city_list ( index );
  t = temp_list ( index ) + 10.0 * randn ( n, 1 );

  return
end

