Re: Position in the importing loop from a Web

*To*: mathgroup at smc.vnet.net*Subject*: [mg125237] Re: Position in the importing loop from a Web*From*: Bob Hanlon <hanlonr357 at gmail.com>*Date*: Thu, 1 Mar 2012 05:35:08 -0500 (EST)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com

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=StringPosition[s,"Flux Light Curve"],{i,1,Length[data4]}] s has been split into lines. You are testing each line searately. Most lines do not contain the target string and therefore produce {}. The lines with the target string are tgtLines=Position[line, {__},1]//Flatten {230,294,295} These lines are s[[tgtLines]]//Column <h2>Flux Light Curve</h2> <li><a href="/xrt_curves/00111529/flux.ps">Flux Light Curve (postscript)</a></li> <li><a href="/xrt_curves/00111529/flux.qdp">Flux Light Curve (ascii data)</a></li> The target strings' character positions on these lines are pos=Flatten[line[[tgtLines]],1] {{9,24},{50,65},{51,66}} Or, alternatively pos=Flatten[line/.{}->Sequence[],1] {{9,24},{50,65},{51,66}} Verifying that the target string was found on those lines and at those positions StringTake[s[[#[[1]]]],#[[2]]]&/@Thread[{tgtLines,pos}] {Flux Light Curve,Flux Light Curve,Flux Light Curve} Bob Hanlon On Tue, Feb 28, 2012 at 6:13 PM, maria giovanna dainotti < mariagiovannadainotti at yahoo.it> wrote: > Hi Bob, > unfortunately it is not still working: > This is the output. > I should have just {{}} and a number. I am grateful of any further help > > {{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {{8, > 32}}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, \ > {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}} > > > 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: [mg125158]Position in the importing loop from a Web > > A: "maria giovanna dainotti" <mariagiovannadainotti at yahoo.it> > Cc: adriano.pascoletti at uniud.it, hmichel at cox.net, djorser at comcast.net, > ulrich.arndt at data2knowledge.dev, mathgroup at smc.vnet.net > Data: Marted=EC 28 febbraio 2012, 23:37 > > > If you look at the documentation for Position, the See Also section > includes StringPosition. Since you are working with strings, you might want > to try that. > > Alternatively, the section on String Operations (guide/StringOperations) > lists the operations used on strings. > > 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=StringPosition[s,"Flux Light Curve"],{i,1,Length[data4]}] > > > Bob Hanlon > > On Tue, Feb 28, 2012 at 4:57 PM, maria giovanna dainotti < > mariagiovannadainotti at yahoo.it<http://mc/compose?to=mariagiovannadainotti at yahoo.it> > > wrote: > > 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<http://mc/compose?to== hanlonr357 at gmail.com> > >* ha scritto: > > > Da: Bob Hanlon <hanlonr357 at gmail.com<http://mc/compose?to=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<http://mc/compose?to=mariagiovannadainotti at yahoo.it> > > > Cc: hmichel at cox.net <http://mc/compose?to=hmichel at cox.net>, > adriano.pascoletti at uniud.it<http://mc/compose?to=adriano.pascoletti at uniud.it>, > djorser at comcast.net <http://mc/compose?to=djorser at comcast.net>, > ulrich.arndt at data2knowledge.dev, "mathematica group" < > mathgroup at smc.vnet.net <http://mc/compose?to=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 < > 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 > >

**Re: How add a menu item with a menu key using an init.m**

**Re: Problems getting DLL Functioncalls to work properly**

**Re: How add a menu item with a menu key using an init.m**

**Animate reevaluates the expression on every change**