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 8367259
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T13:06:48+00:00 2026-06-09T13:06:48+00:00

My question is, does the map/zipmap step (below) run the risk of consuming too

  • 0

My question is, does the map/zipmap step (below) run the risk of consuming too much memory, if the .csv file were large enough?

I have a sequence-of-sequences returned from clojure-csv. The following steps are deliberately separated for clarity. In other words, I’d be combining some of these in production code.

; Process the .csv file
(defn fetch-csv-data
    "This function accepts a csv file name, and returns parsed csv data,
     or returns nil if file is not present."

    [csv-file]
        (let [csv-data (ret-csv-data csv-file)]
            csv-data))

(def bene-csv-inp  (fetch-csv-data "benetrak_roster.csv"))

; Pull out the columns/keys, and
(def bene-csv-cols (map #(cstr/trim %1) (first bene-csv-inp)))

; create the keys.
(def bene-csv-keys (map #(keyword %1) bene-csv-cols))

; Make a sequence of just one of the keys:

(def test-ssns2 (map (fn [x] (:GIC-ID x)) 
                (map #(zipmap gic-csv-keys %1) gic-csv-data)))

Thanks.

  • 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-06-09T13:06:49+00:00Added an answer on June 9, 2026 at 1:06 pm

    the only way this code will leak memory is because the defs will hold the heads of the lazy sequences. if you replace them with functions which return the sequence then the actual head will only exist in the call stack and be handled properly by lazy evaluation.

    (defn bene-csv-inp [] (fetch-csv-data "benetrak_roster.csv"))
    
    ; Pull out the columns/keys, and
    (defn bene-csv-cols [] (map #(cstr/trim %1) (first (bene-csv-inp))))
    
    ; create the keys.
    (defn bene-csv-keys [] (map #(keyword %1) (bene-csv-cols)))
    

    It’s a rough rule of thumb, though sometimes useful, to replace defs with defn‘s when they contain infinite sequences, and make them called everywhere instead of read (unless you really want the caching benefits of a lazy sequence for multiple readers, and the sequence is only going have a reasonable amount of data read).

    using function calls instead of reading the defs here will almost certainly not have any effect on runtime once the hotspot compiler finishes with it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've a question about using sqlSave. How does R map RODBC data in the
Simple question: does the Java memory/synchronization model guarantee atomic pointer writes? That is, if
This question does pretty much what I want to accomplish, but my table is
Question:- Does java client need to worry about multiple servers ? Meaning:- I have
[Question] Does anyone product release notes via an automated process? If so how. Especially
Question: Does anyone have an example of a filter as you type dropdown control
Question: Does anyone have a quick way for removing all the extra resources in
The question does not refer to some Vim-mode in Emacs, but to Vim inside
(This question does not rely on a specific IoC framework, so the interfaces and
Drupal Question: Does anyone have a method of using Views and highlighting a selected/current

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.