Re: Position in the importing loop from a Web
- To: mathgroup at smc.vnet.net
- Subject: [mg125211] Re: Position in the importing loop from a Web
- From: maria giovanna dainotti <mariagiovannadainotti at yahoo.it>
- Date: Wed, 29 Feb 2012 07:23:32 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
Dear Adriano and Bob, thanks for the further suggestion, I am implementing the code data4 = {{"050318", "111529"}} Do[ ID2 = data4[[i, 2]]; s = Import["http://www.swift.ac.uk/xrt_curves/00" <> ID2, "Text"]; s = StringSplit[s, "\n"]; line = Position[s, "Flux Light Curve"], {i, 1, Length[data4]}] The stringSplit works properly, but when I want to identify the position it gives line {} empty I expect instead a number like {{106}} for example I am grateful if you could help. Best regards, Maria --- Mar 28/2/12, Bob Hanlon <hanlonr357 at gmail.com> ha scritto: Da: Bob Hanlon <hanlonr357 at gmail.com> Oggetto: Re: I: RE: adding a string to a list of number in the importing loop from a Web A: "maria giovanna dainotti" <mariagiovannadainotti at yahoo.it> Cc: hmichel at cox.net, adriano.pascoletti at uniud.it, djorser at comcast.net, ulrich.arndt at data2knowledge.dev, "mathematica group" <mathgroup at smc.vnet.net> Data: Marted=EC 28 febbraio 2012, 04:42 I recommend that you go to the virtual book and read the sections on strings. data4 = {{"050318", "111529"}, {"050401", "113120"}}; Do[ID = data4[[i, 2]]; s = Import["http://www.swift.ac.uk/xrt_curves/" <> "00" <> ID, "Text"]; Print[s], {i, 1, Length[data4]}] Bob Hanlon On Mon, Feb 27, 2012 at 9:00 PM, maria giovanna dainotti <mariagiovannadain otti at yahoo.it> wrote: Dear All, thanks for the previous suggestions all of them worked. I have a long list of elements (I just took two as example) data4 = {{"050318", "111529"}, {"050401", "113120"}} and I would like to add in the second element 00 When I try Do[ ID = data4[[i, 2]]; s = Import["http://www.swift.ac.uk/xrt_curves/" <> 00 ID, "Text"]; Print[s], {i, 1, Length[data4]}] This does,'t work As well as the following: Do[ ID = data4[[i, 2]]; s = Import["http://www.swift.ac.uk/xrt_curves/" <> "00" ID, "Text"]; Print[s], {i, 1, Length[data4]}] As well as this again Do[ ID = data4[[i, 2]]; s = Import["http://www.swift.ac.uk/xrt_curves/" <> "00ID", "Text"]; Print[s], {i, 1, Length[data4]}] Is it a problem of the position of " " or something else? Thanks a lot, regards, Maria --- Sab 25/2/12, Hans Michel <hmichel at cox.net> ha scritto: Da: Hans Michel <hmichel at cox.net> Oggetto: RE: Importing data from the web A: "'maria giovanna dainotti'" <mariagiovannadainotti at yahoo.it>, mathgroup at smc.vnet.net Data: Sabato 25 febbraio 2012, 16:52 Maria: Try data4 = {{"050318", "00111529"}, {"050401", "00113120"}}; Do[ ID = data4[[i, 2]]; url = "http://www.swift.ac.uk/xrt_curves/" <> ID ; s = Import[url, "Text"]; Print[s], {i, 1, Length[data4]} ] The string join you were attempting did not work. I moved the concatenation of the url string external to the Import this way if you wish to test if the url exist before import you can. Somewhere on MathGroup there is code to test for existence of a URL. Hans -----Original Message----- From: maria giovanna dainotti [mailto:mariagiovannadainotti at yahoo.it] Sent: Saturday, February 25, 2012 12:55 AM To: mathgroup at smc.vnet.net Subject: [mg125211] Importing data from the web Dear Math Group, I have a problem importing the data from a web page. data4 = {{"050318", "00111529"}, {"050401", "00113120"}} Do[ ID = data4[[i, 2]]; s = Import["http://www.swift.ac.uk/xrt_curves/<>ID<>", "Text"]; Print[s], {i, 1, Length[data4]}] The error message is $Failed I am really grateful if you could help me Best regards, Maria -- Bob Hanlon