Hot answers tagged

10

Unfortunately this is indeed a bug and it's fixed for the next version. The workaround is to use ExtractArchive first, then Import the resulting files. You can extract specific files from an archive using the 3rd argument.


7

First, import the string. In your case it'll just be Import["name of the file.txt", "Data"] s = ImportString["r&=3&a&=3&b&=4&c&=10\\\\ r&=3&a&=8&b&=15&c&=120\\\\ r&=3&a&=20&b&=55&c&=1540\\\\ r&=4&a&=34&b&=119&c&=7140\\\\ r&...


6

Just for completeness: it is also possible to do all this with just using options for Import: data=Import[fname, {"Table", "Data", All, {2, 4}},"FieldSeparators"->{"=", "&", "\\\\"}] see the documentation for the "Table" format for details: http://reference.wolfram.com/language/ref/...


5

Yep. You can do this no problem. I suggest looking at the documentation on the workflow in NotebookEvaluate[]. For example, create another notebook with the following contents. Table[ NotebookEvaluate["/path/to/previous/notebook.nb"], {k, k_min, k_max}] I'd suggest that maybe a simpler way would be to confine operations to a single note book with ...


5

You seem to have a problem that Excel puts some errors containing string expressions. If they appear in random places but you know how they look you can delete them based on their pattern. After you import: data=ToExpression[Import["https://pastebin.com/raw/rSVRyTge"]]; you can remove them whether by exact pattern DeleteCases[data,{"",-6 ...


3

Just download and unzip the CSV file and then run: data = Import["path/to/ICIO2018_2015.CSV"]; Dimensions[data] {2552, 2876}


3

Here's one possible approach: SetAttributes[toexpr, Listable]; toexpr[str_] := ToExpression[str, TeXForm] importlatexmat[str_] := toexpr@ImportString[str, "Table", "FieldSeparators" -> {"\\\\", "&"}, "Numeric" -> False] "0& 0& 1 \\\\ 1& 0& 0 \\\\ 0& 1& 0" // ...


3

Import["path to txt"] // StringSplit[#, {"\\\\"}] & // Map[StringSplit[#, {"&=", "&"}] &] // #[[All, {2, 4}]] & // ToExpression // ListPlot


3

For now, here is another way to extract the data and group it by county. I typically prefer to use Associations rather than lists of rules in Mathematica, mostly for ease of use (I've never really gotten my head around the "Geometry" /. data semantics). Let's start by reading the shapefile and converting it into an association (in this case, we ...


2

I downloaded BS.DAT from the link you provided, then temp = Import["~/Downloads/BS.DAT", "Table"]; ListPlot3D[temp]


2

Import[\path\Bs.dat,"Table"]>>temp reads data from a file Bs.dat and writes it to a file named temp. To define a symbol temp to hold the data for further processing by Mathematica, use temp=Import[\path\Bs.dat,"Table"] instead.


2

Now that I can access the data file, I can provide a more complete answer. First, here are a few functions: (* FUNCTION: input a shape file and returns a data file *) shapeFileToData[path_] := ( First@Import[path, "Data"] ) (* FUNCTION: Extract the top rules left side *) getRulesLeft[data_] := (data /. Rule[a_, b_] :> a) (* FUNCTION: ...


2

Here's my solution: SetAttributes[toexpr, Listable]; toexpr[str_] := ToExpression[str, TeXForm] importlatexmat[str_] := toexpr@ImportString[str, "Table", "FieldSeparators" -> {"\\\\", "&"}, "Numeric" -> False] importlatexmat@"{0} & {0} & {0}\\\\ {\\sqrt{2}} & {0} & {0}\\\...


2

While it is possible to use NotebookEvaluate for such purposes, I think it will be worth to learn the more recommended ways to automate your tasks: you can write scripts in text-only files which can end in either .m or .wl and run these either from the command line or by simply doing Get["/path/to/script"]. Even better is to learn how to write ...


1

The command: temp123 = temp1234[[All, {1, 2, 3}]]; solve the problem.


1

A related, but potentially more flexible approach than Daniel Huber's. First do the most minimal transformations necessary to allow Mathematica to interpret this as an expression hexpr = "H(2,2,x),H(2,1,x),H(2,1,2,x),H(1,2,3,4,x),H(1,2,3,4,5,x)" // StringReplace[{"(" -> "[", ")" -> "]"}] // ...


1

I see an already accepted answer, which I agree with. I am writing this answer as really an extended comment, which I think too long for the usual comment. I frequently use NotebookEvaluate[] for the purpose described. To place this in context, I offer an example of a data analysis routine. The routine is written as a notebook. It loads several images which ...


1

Since OP mentions he was in version 5, I'd like to talk about how to handle the problem therein. ListPlot3D cannot be used as noticed by OP, because ListPlot only handles 2D array at that time. (This is the first syntax in the document of ListPlot nowadays BTW. ) I think the most general work-around is to build a InterpolatingFunction first and plot with ...


Only top voted, non community-wiki answers of a minimum length are eligible