The tag has no usage guidance.

learn more… | top users | synonyms

39
votes
1answer
1k views

Local variables in Module leak into the Global context

From the Mathematica documentation on Module: Module allows you to set up local variables with names that are local to the module. But after using ...
17
votes
2answers
375 views

Why doesn't Mathematica use uniform criteria for validating Options?

Plot[Sin[x], {x, 0, 1}, pp -> 0] Gives as expected: Plot::optx: Unknown option pp in Plot[Sin[x],{x,0,1},pp->0]. >> However: ...
15
votes
2answers
385 views

Shell Emulation inside Mathematica

I am trying to create a Mathematica/shell syntax hybrid. I would like the following command wget -qO- "http://google.com/space line break\"" $var to be ...
14
votes
2answers
446 views

Tokenize Mathematica input in a simple way

Background Usually, I give detailed descriptions when I have a question which sometimes lead to that users don't write their answers because they maybe think their answer is too simple. Therefore, I ...
13
votes
4answers
338 views

balanced Shortest[] and string-patterns

The pattern Shortest["A"~~__~~"B"] is oriented : It assumes the text is read from left to right and it takes the text between the first "A" and the next "B". Any "A"...
13
votes
2answers
752 views

Parsing a CSV file using Interpreter

The new Interpreter functionality in version 10 looks like it has the potential to make parsing custom data formats very easy. I'm trying to create a CSV parser. ...
11
votes
2answers
1k views

Light syntax parser for Mathematica?

My netbook is too slow to install Mathematica. I'm not set against working in a text editor, but I like having an automated highlighting/formatting environment; can anyone recommend a good gedit ...
10
votes
4answers
434 views

What is the correct way to use specific rule for specific pattern match when parsing an expression?

update: Thanks for the answers below. But I noticed they do not handle the following special cases: lis=1 and lis=z , ...
10
votes
2answers
229 views

How to parse a clojure expression?

Clojure is a lisp-like language that runs on JVM and in Javascript. I just started learning it and I'm building a simple parser with Mathematica to understand and visualize it. Like other lisps every ...
8
votes
3answers
868 views

How to parse information contained in a file name

I have a set of files containing my data, and the file-names contain relevant information that I would like to extract. What I have is: ...
8
votes
1answer
154 views

Bug in grouping after editing code?

Bug introduced in 7.0 or earlier and persisting through 10.4.1 or later While looking at A question about conditional replacement I think I discovered a bug in the Front End that affects both 7.0.1 ...
7
votes
2answers
334 views

Using MatchQ (or other means) to parse an expression using sums of COS or SIN correctly

I am writing a function that will take an expression as input. I want to make sure the expression is valid first before processing it. Looking for a correct to use ...
7
votes
1answer
351 views

View the FullForm of ^^

Why am I unable to see the FullForm of ^^ (the shorthand notation for BaseForm)? ...
7
votes
1answer
272 views

How to programmatically replace an expression in a .m file

I'm trying to write some code to programmatically replace a particular expression in my init.m file with a different expression. (It'll probably be some multi-line ...
7
votes
1answer
761 views

Efficient JSON parser for Mathematica

Im looking for a efficient way of parsing JSON data in Mathematica. I am having a lot of problems with ImportString because it uses Java, is too slow, and uses too ...
6
votes
2answers
699 views

How to import a “.numbers” spreadsheet?

Does Mathematica support importing a ".numbers" spreadsheet file (from the "Numbers" '09 (ver. 2.3 554) spreadsheet program in Apple's OS X iWork office suite)? A ".numbers" file is actually a zip ...
6
votes
1answer
284 views

On Reverting Code that Mma Switches to Raw Input Form Back to Standard Form

I experienced a similar issue to what is described in this post while editing formatted usage messages (that contained italics) in the declaration section of a package that I'm developing in the ...
5
votes
5answers
348 views

Isolating characters in a string

I'm struggling to find the right function in mathematica to isolate specific characters in a string. I have got a formula as string (I imported it from an excelfile) like this: y = 0.97*x1 + 0.521*...
5
votes
1answer
94 views

How to get “one Cell - one line” code format inside of NB files?

The PageWidth option controls the way the Cell's content is displayed, not the manner it's written in a ...
4
votes
1answer
142 views

When does Mathematica insert parenthesis into expression?

expr//HoldForm usually returns identical expressions as input, but sometimes parenthesis are inserted. I tried to interpret this behavior as an attempt to eliminate ...
4
votes
1answer
74 views

How to get the list of links in a Wikipedia article in order of appearance

I can get a list of links in a Wikipedia article using WikipediaData: ...
4
votes
2answers
109 views

Parsing tab delimited file

Problem Description I have my data arranged in a tab delimited file and I'm trying to parse/access certain parts of it. As an example, I'd like to extract the number of points and the sampling ...
4
votes
1answer
145 views

Parsing string with nested information

I am trying to parse a string, but I have no idea how to solve the following problem ...
4
votes
1answer
569 views

Extracting text from nested HTML lists <ul> <li>

We wish to analyze the tree structure of HTML documents that consist of nested lists, ie, using the HTML tags <ul> and ...
3
votes
1answer
500 views

Easiest way to parse semi-structured text file

I have a plain text file with some data. I need two things: Be able to extract certain values for the various field, e.g. to extract the 'Mean Dose [%]', that is to extract number ...
3
votes
1answer
43 views

`ReadString` and `StreamPosition` behaving strangely with custom terminators

I've stumbled on a strange behavior while trying to use custom terminators for ReadString. When I use a simple String as the ...
3
votes
1answer
34 views

Skipping commented in a stream from OpenRead

Is there a solution to skip comments in text files that are imported with OpenRead? I know there are solutions for Importand <...
3
votes
1answer
110 views

Why is ^^ff not the same as ^^ToExpression[“ff”]?

I want to convert a hexadecimal string to a decimal (base 10) number: 16^^ff 16^^ToExpression["ff"] The 1st line returns the correct answer of 255, while the 2nd ...
2
votes
1answer
92 views

Make MyLogicalExpand

The function by Mathematica to expand a formulation with ANDS, ORS, NOT, XOR, and others, is LogicalExpand, let see an example: ...
2
votes
0answers
65 views

Where do the radicals end?

In an early iteration of this question on the Mathematics SE, the radicals weren't properly formatted, so they only had the √ symbol with no indication of which terms were supposed to be ...
1
vote
1answer
172 views

how to make a recursive function to analyse this file

I am stuck at this problem beginning We assume we have keyword k, and the structure in the file: file.txt ...
0
votes
2answers
108 views

Extracting part of an expression

My goal is to solve $(\alpha - \dfrac{1}{\alpha}) - (\beta- \dfrac{1}{\beta}) = \dfrac 1 n$ where $\alpha$ and $\beta$ are rational and $n$ is a positive integer. Towards finding a particular solution,...
0
votes
0answers
69 views

How to prevent space trimming when importing HTML with ImportString?

I am importing a HTML-formatted string with ImportString[string, "HTML"] to properly parse all HTML-escaped characters like ...
0
votes
0answers
37 views

Get determinate values from XML [duplicate]

The following code gets a xml file with too much attributes of a car, but I want some of them only, what is the best way to do it? ...
0
votes
0answers
44 views

parsed matrix not deleting elements in adjusted matrix

I have a matrix that has been parsed to delete certain rows and columns, as well as delete certain elements on the diagonal on the matrix. The problem is that it does this in theory when i take the ...