Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6831495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:44:38+00:00 2026-05-26T22:44:38+00:00

I exported my matlab structs to text files so that I can read them

  • 0

I exported my matlab structs to text files so that I can read them in clojure.
I have a text file like:

name
Ali
age
33
friends-ages
30
31
25
47

know I can read this file, but what’s the clojure way to convert it into something like:

(def person1 
    {:name "Ali"
     :age  33
     :friends-ages [30 31 25 47]})

or lets make it easier:

name
Ali
age
33

to:

(def person1 
    {:name "Ali"
     :age  33})
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T22:44:39+00:00Added an answer on May 26, 2026 at 10:44 pm

    I ended up writing an .m file to export my .mat files to text, then imported them by something like the following:

    (use '[clojure.string :only (split join)])
    
    (defn kv [[k v]] 
      [(keyword k) v])
    
    (let [a (split (slurp (java.io.FileReader. fileName)) #"\n")]
          (def testNeuron (into {} (map kv (partition 2 a)))))
    

    Thanks to the answers by Hamza and Jouni.
    The actual code is more like this:

    (def dataPath "/home/ali/Dropbox/Projects/Neurojure/")
    (def testFileName "dae062.c1.cylinder.DID.txt")
    
    (defn kv [[k v]] 
      [(keyword k)
      (if (< 0 (count (re-seq #"\d\d\d\dSpikes|\d\d\d\dOcodes|\d\d\d\dOSpikes" k)))
        (into [] (map (fn [x] (Integer/valueOf x)) (split v #",")))
       (try (Integer/valueOf v) 
         (catch NumberFormatException _ v)))])
    
    
    (let [a (split (slurp (java.io.FileReader. (str dataPath testFileName))) #"\n")]
          (def testNeuron (into {} (map kv (partition 2 a)))))
    

    and the converted data file looks like this:

    ConvertDate
    18-Nov-2011
    Name
    /bgc/data/dae/062/dae062.mat
    frameperiod
    83.2500000037253
    Spike2Version
    1.27
    unstored
    167
    rfstr
    cm=rf-3.10,9.61:0.00x0.00,-135deg pe20 -2.0,-3.0 fx=0.00,fy=0.00cm=rf-3.10,9.61:0.00x0.00,-135deg pe20 -2.0,-3.0 fx=0.00,fy=0.00
    rf
    -3.1,9.61,0,0,-135,20,-2,-3,0,0
    trange
    47371169.75,100193717.5
    psych
    1
    rc
    0
    Options
    
    expname
    cylinder.dxXIdD
    Start
    94745610.75
    End
    100193717.5
    Area
    MT
    Ex
    perimenter Ali
    Trial=>0001Start
    47377343
    Trial=>0001TrialStart
    47377343
    Trial=>0001End
    47397224.25
    Trial=>0001dur
    19881.2500000075
    Trial=>0001uStim
    0
    Trial=>0001op
    40980
    Trial=>0001Trial
    1860
    Trial=>0001id
    15897
    Trial=>0001Startev
    47377149.5
    Trial=>0001serdelay
    -46.25
    Trial=>0001bstimes
    47377195.75
    Trial=>0001delay
    147.25
    Trial=>0001TrueEnd
    47397224.25
    Trial=>0001CorLoop
    0
    Trial=>0001dx
    0
    Trial=>0001Spikes
    -1402,-1232,1577,1931,2165,2222,2478,2773,2903,3229,3745,3820,4071,4588,4920,5141,5752,6440,6490,6664,6770,7042,7958,8081,8307,8622,8732,9021,9082,9343,9619,9695,9877,10357,10668,10943,11105,11364,11720,12272,12499,12762,12907,13621,14121,14351,14542,14588,15104,15420,15501,16331,16596,16843,17476,17698,17996,18169,18401,18532,18706,19029,19081,19418,19603,19750,20222
    Trial=>0001count
    65
    Trial=>0001OptionCode
    +do+aa+sq+72+se+fc+fb+ap+wt+cf+ws+ts+sw+bw+cs+2a+bm+gm+x2+sp+da+ao+cS+C3+CF
    Trial=>0001me
    0
    Trial=>0001OSpikes
    -1976,-1802,-1423,-1360,-1268,-1248,-1140,-244,-220,-164,632,681,730,760,779,786,867,879,924,1062,1161,1252,1268,1431,1533,1632,1946,2210,2235,2273,2285,2296,2305,2496,2532,2541,2732,2787,2806,2822,2840,3095,3292,3431,3598,3614,3837,4100,4482,4504,4515,4651,4768,4794,4936,5020,5160,5184,5300,5314,5710,5764,6431,6453,6471,6553,6561,6584,6791,7018,7124,7880,7905,7940,7968,8011,8315,8330,8352,8568,8666,8748,8756,8766,8797,8836,9038,9297,9328,9360,9471,9632,9639,9721,9939,10196,10363,10375,10387,10410,10931,10953,10969,10986,11038,11118,11135,11405,11692,12018,12163,12258,12492,12512,12525,12884,12899,12919,13156,13183,13638,13674,13842,13988,14110,14298,14310,14321,14606,14617,15124,15132,15150,15289,15341,15620,16293,16305,16342,16364,16441,16604,16692,16932,16997,17059,17086,17210,17368,17495,17626,17639,17651,17677,17718,18013,18247,18353,18553,18691,18722,18887,18941,19438,19774,19938,19959,19967,20004,20240,20306,20500,20623
    Trial=>0002Start
    47406914
    Trial=>0002TrialStart
    47406914
    Trial=>0002End
    47426795.25
    Trial=>0002dur
    19881.2499999925
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have exported data from a text file to an excel sheet, with the
If I have exported a .sql file with my database in it, can I
I have exported a COM+ application proxy, which generates MSI and CAB files, and
I have this exported file of some weird (standard for this industry!) format, which
How to make exported .XLS file Editable Thid code makes .XLS File Read Only
We have some stuff that may be exported into various formats. Currently we have
I have csv file exported from access. (dates formatted to match mysql) I need
I have a some exported rows that I want to import into a database
I've exported records to a flat file delimited by | and it seems that
I have files being exported by Excel for Mac 2011 VBA in Western (Mac

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.