Re: adding a string to a list of number in the importing loop from a Web
- To: mathgroup at smc.vnet.net
- Subject: [mg125216] Re: adding a string to a list of number in the importing loop from a Web
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Wed, 29 Feb 2012 07:25:17 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
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 < mariagiovannadainotti 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: 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