(* Content-type: application/vnd.wolfram.mathematica *) (*** Wolfram Notebook File ***) (* http://www.wolfram.com/nb *) (* CreatedBy='Mathematica 10.1' *) (*CacheID: 234*) (* Internal cache information: NotebookFileLineBreakTest NotebookFileLineBreakTest NotebookDataPosition[ 158, 7] NotebookDataLength[ 5995, 156] NotebookOptionsPosition[ 5689, 140] NotebookOutlinePosition[ 6024, 155] CellTagsIndexPosition[ 5981, 152] WindowFrame->Normal*) (* Beginning of Notebook Content *) Notebook[{ Cell[CellGroupData[{ Cell[BoxData[{ RowBox[{ RowBox[{"ClearAll", "[", "\"\\"", "]"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ StyleBox["folder", Background->RGBColor[1, 0.85, 0.85]], StyleBox[" ", Background->RGBColor[1, 0.85, 0.85]], StyleBox["=", Background->RGBColor[1, 0.85, 0.85]], StyleBox[" ", Background->RGBColor[1, 0.85, 0.85]], "\"\\""}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{ StyleBox["dims", Background->RGBColor[1, 0.85, 0.85]], StyleBox["=", Background->RGBColor[1, 0.85, 0.85]], RowBox[{"{", RowBox[{"600", ",", "600"}], "}"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"fldrPaths", " ", "=", RowBox[{"FileNames", "[", RowBox[{"\"\<*\>\"", ",", "folder"}], "]"}]}], ";"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"filePaths", " ", "=", " ", RowBox[{ RowBox[{ RowBox[{"FileNames", "[", RowBox[{"\"\<*.bin\>\"", ",", "#"}], "]"}], "&"}], "/@", "fldrPaths"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{"importBin", "[", RowBox[{"path_", ",", "dims_"}], "]"}], ":=", RowBox[{"(", "\[IndentingNewLine]", RowBox[{"ArrayReshape", "[", "\[IndentingNewLine]", RowBox[{ RowBox[{"Import", "[", RowBox[{"path", ",", "\"\\""}], "]"}], ",", "\[IndentingNewLine]", "dims"}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"bin2csv", "[", RowBox[{"fName_", ",", "dims_"}], "]"}], ":=", RowBox[{"(", "\[IndentingNewLine]", RowBox[{ RowBox[{"dat", " ", "=", RowBox[{"importBin", "[", RowBox[{"fName", ",", "dims"}], "]"}]}], ";", "\[IndentingNewLine]", RowBox[{"newFolder", " ", "=", " ", "\[IndentingNewLine]", RowBox[{"folder", "<>", "\"\\"", "<>", "\"\\"", "<>", RowBox[{"FileNameTake", "[", RowBox[{"fName", ",", RowBox[{"{", RowBox[{"-", "2"}], "}"}]}], "]"}]}]}], ";", "\[IndentingNewLine]", RowBox[{"If", "[", RowBox[{ RowBox[{"FileExistsQ", "@", "newFolder"}], ",", "Null", ",", RowBox[{"CreateDirectory", "@", "newFolder"}]}], "]"}], ";", "\[IndentingNewLine]", RowBox[{"newPath", "=", RowBox[{"newFolder", "<>", "\"\\"", "<>", RowBox[{"FileBaseName", "@", "fName"}], "<>", "\"\<.csv\>\""}]}], ";", "\[IndentingNewLine]", RowBox[{"Export", "[", RowBox[{"newPath", ",", "dat"}], "]"}], ";", "\[IndentingNewLine]", "newPath"}], "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", RowBox[{ RowBox[{ RowBox[{"bin2csv", "[", RowBox[{"#", ",", "dims"}], "]"}], "&"}], "/@", RowBox[{"Flatten", "@", "filePaths"}]}]}], "Input", CellChangeTimes->{{3.653593123207206*^9, 3.653593192543738*^9}, { 3.653593264785576*^9, 3.653593393713743*^9}, {3.653593547339282*^9, 3.6535936485519323`*^9}, {3.653593690889806*^9, 3.653593745997469*^9}, { 3.653593778575828*^9, 3.653594002868764*^9}, {3.653594033623508*^9, 3.653594101292755*^9}, {3.65359415915658*^9, 3.653594277442725*^9}, { 3.65359431331129*^9, 3.653594435743081*^9}, {3.6535944662401543`*^9, 3.65359455275408*^9}, {3.653594591543379*^9, 3.6535946565342903`*^9}, { 3.653594723363305*^9, 3.653594730566144*^9}, {3.653594923462501*^9, 3.653594923864509*^9}, 3.653595002940288*^9, {3.653595092662908*^9, 3.65359509712986*^9}, {3.6535951541507473`*^9, 3.65359515474431*^9}, { 3.65362847987166*^9, 3.6536285086031437`*^9}, {3.65362865298593*^9, 3.6536286681155*^9}, {3.6536291488705807`*^9, 3.653629152568234*^9}, { 3.653629185112349*^9, 3.653629214247445*^9}, {3.653813726440426*^9, 3.653813749729107*^9}, {3.653813873199418*^9, 3.653813877033496*^9}, { 3.653865901370187*^9, 3.65386591554218*^9}, {3.654898202908464*^9, 3.6548982046496058`*^9}, {3.6639312039238367`*^9, 3.6639312349208803`*^9}, {3.663931282916544*^9, 3.66393128867024*^9}, { 3.6639313539109077`*^9, 3.6639313759578342`*^9}, {3.663931446685445*^9, 3.663931519430182*^9}, {3.663931619940916*^9, 3.6639317393058147`*^9}, { 3.663931891670237*^9, 3.6639318918126173`*^9}, {3.663931984820076*^9, 3.6639319932901287`*^9}, {3.663932101467882*^9, 3.663932129205824*^9}, 3.6639321663302507`*^9, {3.66393224971279*^9, 3.663932250571526*^9}, 3.6639323541434383`*^9, {3.663932455008795*^9, 3.663932455294909*^9}, { 3.663932572988379*^9, 3.663932575829862*^9}}], Cell[BoxData[ RowBox[{"{", \ "\<\"/home/tc/Desktop/test/CSVs/fldr/PredictedIntensity_Method-Abs_Z-0.000000.\ csv\"\>", "}"}]], "Output", CellChangeTimes->{ 3.663931746152172*^9, 3.6639318926878233`*^9, 3.6639319942697573`*^9, { 3.663932122567593*^9, 3.663932130090919*^9}, {3.663932167210528*^9, 3.663932187809065*^9}, 3.663932259353415*^9, {3.663932331498788*^9, 3.663932360419965*^9}, 3.663932462554063*^9}] }, Open ]] }, WindowSize->{682, 718}, WindowMargins->{{-9, Automatic}, {Automatic, -8}}, FrontEndVersion->"10.1 for Linux x86 (64-bit) (March 23, 2015)", StyleDefinitions->"Default.nb" ] (* End of Notebook Content *) (* Internal cache information *) (*CellTagsOutline CellTagsIndex->{} *) (*CellTagsIndex CellTagsIndex->{} *) (*NotebookFileOutline Notebook[{ Cell[CellGroupData[{ Cell[580, 22, 4666, 105, 583, "Input"], Cell[5249, 129, 424, 8, 55, "Output"] }, Open ]] } ] *) (* End of internal cache information *)