Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature Request: Change of field types #13

Open
Infiziert90 opened this issue Mar 16, 2021 · 4 comments
Open

Feature Request: Change of field types #13

Infiziert90 opened this issue Mar 16, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@Infiziert90
Copy link

Is it possible to get support for changing the type of a field?

For example:
The .dbf file has a "Numeric" field that would be changed into a "Character" field

@tmontaigu tmontaigu added the enhancement New feature or request label Apr 18, 2021
@tmontaigu
Copy link
Owner

I'll try to look into that

@michelk
Copy link
Contributor

michelk commented Jun 15, 2021

In the csv-library it is possible to define the Record-type:

//tutorial-read-serde-03.rs
use std::collections::HashMap;

// This introduces a type alias so that we can conveniently reference our
// record type.
type Record = HashMap<String, String>;

fn run() -> Result<(), Box<Error>> {
    let mut rdr = csv::Reader::from_reader(io::stdin());
    for result in rdr.deserialize() {
        let record: Record = result?;
        println!("{:?}", record);
    }
    Ok(())
}

Maybe we can have something similar?

@tmontaigu
Copy link
Owner

tmontaigu commented Jun 15, 2021

There is already something close to this
https://docs.rs/dbase/0.2.0/dbase/#deserialisation

I think the feature requested here is more about changing a filed type rather than that serialization.

Changing a field type should be doable by reading the file, changing the types in the Record and create the appropriate writer.
The things is can it be made a bit simpler ?

@Infiziert90
Copy link
Author

Yeah that's exactly what I meant.

Where this idea comes from is easy.... In the company I work for we use the old DOS program "DBase" this program allows it you to edit .dbf files both header and body

So you have for example the field
Name: XYZ
Type: Character
Length: 20
Precision: 0

And now you can go and change that "Type" to "Numeric" and the program would create a new dbf file with the correct header and changed body values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants