I wrote a notebook on Mac OS 10.7.4 and run it on Windows XP at work. On my Mac I use a full version of Mathematia 8.0.1.0, whereas on the Windows-system only a trial version (Version 8.0.4.0.).
First of all I cannot run the following code on the Windows system (on Mac it works perfect):
ImportData={{"Test1", 5670.`, 0.`, 180.`, 2756.`, 2443.`, 180.`, 1008.`, 2007.`},
{"Test2", 100.`, 0.`, 3006.`, 1235.`, 9874.`, 4543.`, 3241.`, 5004.`}};
WhitespaceCleaning[string_] :=
StringReplace[
string, (StartOfString ~~ Whitespace) | (Whitespace ~~
EndOfString) :> ""]
OriginalData =
Drop[ImportData, 1] /. {a_, b_, cc_, d_, e_, f_, g_, h_, i_} ->
{WhitespaceCleaning@a, {b, cc, d, e, f, g, h, i}};
However I can get the same result as on my Mac with the following code for my Windows system:
allData=ImportData;
numData=allData[[All,2;;]]
strings0=allData[[All,1]];
stringsWOSpacing=WhitespaceCleaning/@strings0;
OriginalData=Transpose[{stringsWOSpacing,numData}]
The rest of my code runs perfect (I get the same results on both operating systems). However, running my code on Windows provokes many messages (such as Divide::index, Divide::infy, Power::infy, General::stop, Less::nord, LessEqual::nord) which does not happen on my Mac.
I don't understand why Mathematica on my Windows system is acting so odd. Does anyone has an idea?
WhitespaceCleaning@a
is evaluated before any replacement is done, and its argument is not a string, so an error message is issued. TryRuleDelayed
(:>) instead of simply usingRule
(->
). $\endgroup$->
with:>
. Works now on Windows. However, both->
and:>
return the same result on my Mac. I don't understand why "the left hand side of the rule does not match anything in the list". InImportData
I have two lists which do match the pattern{a_, b_, cc_, d_, e_, f_, g_, h_, i_}
. $\endgroup$StringTrim
for your whitespace cleaning: reference.wolfram.com/mathematica/ref/StringTrim.html $\endgroup$