Tag Info

New answers tagged

2

Much more complicated solution, but it doesn't contain anything "illegal" like adding non-string to $Path. It supports multiple notebooks in session chosen with customizable criteria. Add following to your "global" init.m, or e.g. save it in $UserBaseDirectory/Autoload/PathAutoUpdate/init.m file: Begin["PathAutoUpdate`"] (* Variable containing list of ...


1

One thing you could try is to include a function in your $Path that always evaluates to a valid file-name. If you are in a saved notebook, it evaluates to its folder, if not that it maybe evaluates to your user documents directory. A simple solution for this could be nbPath[] := Quiet[With[{p = NotebookDirectory[]}, If[p =!= $Failed, p, ...


1

Rather simplistically, define a function to add the required cell to the end and evaluate a Notebook: updateNotebook[file_] := Module[{nb = NotebookOpen[ToFileName[Directory[], file]]}, SelectionMove[nb, After, Notebook]; NotebookWrite[nb, Cell["Plot[Cos[y],{y,1,10}]", "Input"]]; NotebookEvaluate[nb, InsertResults -> True]; NotebookSave[nb]; ...


3

Your data {a, b, c, d} = RandomInteger[9, 4]; data = a b c d; Exporting with nice file-names featuring date and variable values using StringTemplate Export[ StringTemplate[ "Date`1`_Values_a`2`_b`3`_c`4`.txt" ][DateString[{"Year", "Month", "Day"}], a, b, c] , data] "Date20141201_Values_a7_b5_c3.txt" Or using ToString and StringJoin as ...


4

ReadList[StringToStream@"2014111\\.01ab6f2ed5\\.01ce34cbef", Record, RecordSeparators -> "\\.01"] (*{"2014111", "ab6f2ed5", "ce34cbef"}*) Remove one slash after copying to your notebook for testing.


4

This works. Use BinaryReadList and remove binary 1 which is code for SOH, then convert back to string make file >echo -e "2014111\x01ab6f2ed5\x01ce34cbef" > file.txt Go to Mathematica and type SetDirectory[NotebookDirectory[]]; data = BinaryReadList["file.txt"] data = SplitBy[data, (# != 1 && # != 10) &] data = DeleteCases[data, {1} ...



Top 50 recent answers are included