Jump to content
php.lv forumi
  • 0

node.js nolasīt failam specifisku līniju bez loopa


Wuu

Question

Kā ar node.js nolasīt failam specifisku līniju bez loopa, slice('\n')?

 

Idejiski ir 200+ mb csv fails kuru standartā iemet datubāzē un atrodu ko vajag.

 

Bet gribas node clientu sapakot, un lai nekādas datubāzes nav līdzi jāvazā. Uztaisīju index failu, tagad tik vajag metodi, lai var specifisku līniju tieši nolasīt, nelasot pāri visam failam.

Edited by Wuu
Link to comment
Share on other sites

7 answers to this question

Recommended Posts

  • 0

Failos parasti var aizlekt uz noteiktu pozīciju, nevis rindu, neejot cauri visam failam.

Tātad, ja tu gribi aizlekt uz konkrētu rindu, tev ir vai nu visām rindām jābūt vienādi garām (baitos, nevis simbolos),

vai arī jāuztaisa indekss ar katras rindas sākuma pozīcijām failā.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...