Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.soft-sys.math.mathematica > #8786

Re: Position in the importing loop from a Web

From Bob Hanlon <hanlonr357@gmail.com>
Newsgroups comp.soft-sys.math.mathematica
Subject Re: Position in the importing loop from a Web
Date 2012-02-29 12:25 +0000
Organization Steven M. Christensen and Associates, Inc and MathTensor, Inc.
Message-ID <jil5gi$rot$1@smc.vnet.net> (permalink)

Show all headers | View raw


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@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@gmail.com>* ha scritto:
>
>
> Da: Bob Hanlon <hanlonr357@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@yahoo.it>
> Cc: hmichel@cox.net, adriano.pascoletti@uniud.it, djorser@comcast.net,
> ulrich.arndt@data2knowledge.dev, "mathematica group" <
> mathgroup@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@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@cox.net>* ha scritto:
>
>
> Da: Hans Michel <hmichel@cox.net>
> Oggetto: RE: Importing data from the web
> A: "'maria giovanna dainotti'" <mariagiovannadainotti@yahoo.it>,
> mathgroup@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@yahoo.it]
> Sent: Saturday, February 25, 2012 12:55 AM
> To: mathgroup@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
>

Back to comp.soft-sys.math.mathematica | Previous | Next | Find similar | Unroll thread


Thread

Re: Position in the importing loop from a Web Bob Hanlon <hanlonr357@gmail.com> - 2012-02-29 12:25 +0000

csiph-web