I'd like to convert the following program to 2020 standards (i.e,
replace the foreach block with a one-line code). I've tried much
and I failed.
This is the code that works (1990s style)
--
import std;
void main()
{
immutable URL =
r"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv";
immutable LOCAL = r"local-file";
immutable country = "Poland";
download(URL, LOCAL);
auto file = File(LOCAL, "r");
int i = 0;
foreach(rec; file.byLine())
{
auto x = rec.splitter(',').array;
if (i == 0)
{
// Print Header
writeln(x);
}
else if (x[1] == country)
{
// Print Country Line
writeln(x);
break;
}
i++;
}
}
--