Sunday, April 28, 2024
3
rated 0 times [  3] [ 0]  / answers: 1 / hits: 3199  / 2 Years ago, tue, october 18, 2022, 7:52:24

Is there any way that I can read a few lines of a massive online CSV file using its URL from command line before I am going to download it?


More From » command-line

 Answers
1

An slightly quicker than @musher's would be to do this:



wget http://datagov.ic.nhs.uk/presentation/2014_03_March/T201403PDPI+BNFT.CSV -qO - 


The O will output the results to stdout in the terminal, while the q option supresses stuff about downloading progress etc. You would have to press Ctrl+C fairly quickly to stop it downloading, because as it is text it will download fairly quickly.



This might also work - it should download to stdout the first ten lines:



wget http://datagov.ic.nhs.uk/presentation/2014_03_March/T201403PDPI+BNFT.CSV -qO - | head -10


It should be fine as long as wget stops downloading after the first 10 lines have gone through head... I checked and wget seems to stop downloading after the first 10 lines have been read.
Edit: The wget command will be closed by the signal SIGPIPE - see here



You can change the number of lines read by changing the number after head -


[#24340] Thursday, October 20, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
atelti

Total Points: 194
Total Questions: 129
Total Answers: 110

Location: North Korea
Member since Tue, Jun 16, 2020
4 Years ago
;