Re: importing series of file with the same extension
- To: mathgroup at smc.vnet.net
- Subject: [mg124831] Re: importing series of file with the same extension
- From: Bob Hanlon <hanlonr357 at gmail.com>
- Date: Wed, 8 Feb 2012 05:34:40 -0500 (EST)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- References: <201202070902.EAA23421@smc.vnet.net>
grbs = {"80825593", "80916009", "81006604", "81024891", "81224887", "90217206", "90227772", "90323002", "90328401", "90510016", "90531775", "90626189", "90720710", "90902462", "90926181", "91003191", "91031500", "100116897", "100225115", "100325275", "100414097", "100620119", "100724029", "100728095", "100826957", "101014175", "101123952", "101204343", "110120666", "110328520", "110428388", "110529034", "110625881", "110709642", "110721200", "110731465"}; grid = Table[grbs[[bb]], {bb, 1, Length[grbs]}]; This doesn't accomplish anything since grid == grbs True You defined grbs with strings so none of its elements are numeric. To test whether the elements could be converted to numeric you would use NumericQ[ToExpression[_]]. And, since they are already strings you wouldn't need ToString. However, if you want to handle either strings or numbers you can do both. You need to Map your function onto the elements of your list grbid = If[NumericQ[ToExpression[#]], "0" <> ToString[#], #] & /@ grbs; Import[# <> ".txt", "Table"] & /@ grbid Bob Hanlon On Tue, Feb 7, 2012 at 4:02 AM, maria giovanna dainotti <mariagiovannadainotti at yahoo.it> wrote: > Dear Mathematica group, > I have defined the following code: > > grbs = {"80825593", "80916009", "81006604", "81024891", "81224887", > "90217206", "90227772", "90323002", "90328401", "90510016", > "90531775", "90626189", "90720710", "90902462", "90926181", > "91003191", "91031500", "100116897", "100225115", "100325275", > "100414097", "100620119", "100724029", "100728095", "100826957", > "101014175", "101123952", "101204343", "110120666", "110328520", > "110428388", "110529034", "110625881", "110709642", "110721200", > "110731465"} > > grid = Table[grbs[[bb]], {bb, 1, Length[grbs]}] > If[NumericQ[grid], GRBID = "0" <> ToString[grid], GRBID = grid] > > Data = Import[GRBID <> ".txt", "Table"] > > When I use this last command to import the data file not found during imp= ort. > > The name of the data files are 080825593.txt etc > It gives error anyway also if I change the grbs putting 080825593. > I would be very grateful if you could help me. > > Best regards, > Maria -- Bob Hanlon
- References:
- importing series of file with the same extension
- From: maria giovanna dainotti <mariagiovannadainotti@yahoo.it>
- importing series of file with the same extension