By Micah Maidenberg

CSX Corp. reported weaker earnings and revenue in the second quarter, reflecting how customers pulled back on shipments as the coronavirus slammed the U.S. economy earlier starting earlier in the spring.

CSX, which has rail lines covering much of the Northeast, Midwest and South, said profit fell to $499 million, or 65 cents a share, from $870 million, or $1.08 a share, the year earlier.

Earnings for the latest period were in line with expectations from analysts, according to FactSet.

The company reported a broad-based falloff in demand, with total quarterly volumes dropping 20% year over year.

Volume for chemicals was down 12%, while automotive volume was off 71% and intermodal shipments decreased 11%. Coal volumes dropped 44%.

Revenue for the quarter fell 26 percent year over year to $2.26 billion and was weaker than Wall Street estimates.

The decline in revenue was "primarily due to the lower economic activity driven by the Covid-19 pandemic," CSX said.

The company said expenses fell 19% compared with the second quarter in 2019.

Railroads serving the U.S. and Canada have taken a hit due to the coronavirus-related economic downturn. North American rail volume for the first 28 weeks of the year fell 12% compared with the same stretch in 2019, the Association of American Railroads said last week.

Write to Micah Maidenberg at micah.maidenberg@wsj.com