Coder Social home page Coder Social logo

sav-writer's People

Watchers

 avatar  avatar  avatar

Forkers

hfabio-upsiide

sav-writer's Issues

Example file on how to use the lib to generate a SAV file

Hello! First I want to thank you for sharing the project with the community.

I need to generate (export data in sav format) a SAV data file for SPSS and I found your project on github, but I don't know how to use your lib. I couldn't find documentation or examples.

Could you post an example file (may be a small thing) of how to generate a SAV file using your lib? It will be of great help to me.

Thanks!

Problem with long strings records

I'm passing a correct width (451 for example) and the reader cuts the string WHEN READING BACK (with sav-reader library), and when opening with pspp there is an error message:
error: '/Users/hfabio/test-spss/write.sav' near offset 0x6bc: Incorrect length 451 for the variable XX
I guess that its a bug when relating the variables and records, one can be pointing the correct data length in bytes and the other is just misaligned, but I couldn't figure out the problem properly....

to test, try this:

const {SavFileReader} = require('sav-reader');
const {saveToFile} = require('sav-writer');

const main = async () => {

  const records = [
    {XX: 'this is a short string, we should be good'},
    {XX: 'this is a medium string, lets keep the eyes opened on this problem'},
    {XX: "this is a limit string, it shouldn't raise the problem described because it has 255 characters bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla b bla bla bla bla bla bla bla bla bla bla bla bla bla bla bl"},
    // if you enable this line it breaks:
    // {XX: 'this is the problem string it should raise the problem described because it has 451 characters bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla cuts here -> bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla b bla bla bla bla bla bla bla bla bla bla b'}
  ]
  const variables = [
    {name: 'XX', label: 'X variable', columns: 8, decimal: 0, type: 1, width: 255}
    // enable this one down below and comment above to take the right width
    // {name: 'XX', label: 'X variable', columns: 8, decimal: 0, type: 1, width: 451}
  ]
  saveToFile('test-long-string.sav', records, variables);
  const written = await read('test-long-string.sav');

  const sav = new SavFileReader(filePath);
  await sav.open();
  const rows = await sav.readAllRows();
  const breakpoint = true; // break point here and compare what was read.
}

main()

I'm using macOS and node v18.15.0 by the way.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.