Code Monkey home page Code Monkey logo

Comments (2)

murphyke avatar murphyke commented on August 29, 2024

I see now that the behavior is determined by the REDCap API, not by PyCap. That one bit of documentation could stand to be clarified, however.

from pycap.

sburns avatar sburns commented on August 29, 2024

Thanks for the doc suggestion, @murphyke. You might consider something like this to get you 90% towards a manual export through the API…

project = Project(foo, bar)
field_to_label = {f['field_name']: f['field_label'] for f in project.metadata}
df = project.export_records(format='df')
df = df.rename(columns=field_to_label)
df.to_csv('exported.csv', index_label=project.def_field)

The ordering is difficult to ensure. Also, all the [form_name]_complete columns will not be renamed. Form status fields are unfortunately not in the data dictionary. You might use project.forms to add renaming keys to the field_to_label dict.

Note, the above requires the pandas library. You could just as easily double-loop through the records and keys, but pandas makes so many things so easy.

from pycap.

Related Issues (20)

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.