I have a large txt data stored in this link.
I have tried this:
dataa = ToExpression[
Import["https://www.dropbox.com/s/bkyoamgqop7kpio/data.txt?dl=0",
"JSON"]]
But it's not working.
How can I import this data?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI have a large txt data stored in this link.
I have tried this:
dataa = ToExpression[
Import["https://www.dropbox.com/s/bkyoamgqop7kpio/data.txt?dl=0",
"JSON"]]
But it's not working.
How can I import this data?
There are two issues here. First, that Dropbox gives you a download link that goes to a web page, rather than serving the file directly:
StringTake[ Import[
"https://www.dropbox.com/s/bkyoamgqop7kpio/data.txt?dl=0", "Text"] , 200]
(* <!DOCTYPE html><html xml:lang="en" class="maestro"
xmlns="http://www.w4.org/1999/xhtml"><head><script
nonce="hZ8jZbVPCjAVTxp9v4nc">
window._goch_ = {};
window.addEventListener('click', function(event) *)
If you change the 0
at the end of the URL to a 1
, you get the file:
StringTake[
Import["https://www.dropbox.com/s/bkyoamgqop7kpio/data.txt?dl=1",
"Text"], 200]
(*
41.66666670000001 0. -48.27198359004478
36.458333340625 0. -52.44199291767245
31.249999987500004 0. -55.61381644250923
26.041666640625003 0. -57.787454164553765
20.833333300000003 0. -58.9629060838065
*)
Next, there is the file format - the OP gives "JSON", but I don't think this is a valid JSON file, it looks more like a tab-separated-value file
Import["https://www.dropbox.com/s/bkyoamgqop7kpio/data.txt?dl=\
1", "JSON"]
During evaluation of Import::jsonexpendofinput: Unexpected character found while looking for the end of input.
During evaluation of Import::jsonhintposandchar: An error occurred near character '0', at line 1:20
(* $Failed *)
So just use the "Table" import format:
Import[
"https://www.dropbox.com/s/bkyoamgqop7kpio/data.txt?dl=1",
"Table"] // Short
(* {{41.6667,0.,-48.272},<<19438>>,{37.1875,<<10>>,2193.48}} *)
Import["https://www.dropbox.com/s/bkyoamgqop7kpio/data.txt?dl=1", "TSV"]
works for me. You can also use "Table" as the second argument. $\endgroup$