Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd example: "Filter csv records matching a predicate". #265
Conversation
This comment has been minimized.
This comment has been minimized.
Travis is complaining about line 603: |
This comment has been minimized.
This comment has been minimized.
|
Hi. Travis is not complaining about the specific line. |
This comment has been minimized.
This comment has been minimized.
|
@sotocodes the |
This comment has been minimized.
This comment has been minimized.
|
@budziq error: failed to run custom build command for `openssl-sys v0.9.15`
process didn't exit successfully: `/home/username/_Code/OSS/rust-cookbook/target/debug/build/openssl-sys-169fec58669c2940/build-script-build` (exit code: 101)
--- stdout
cargo:rerun-if-env-changed=OPENSSL_LIB_DIR
cargo:rerun-if-env-changed=OPENSSL_INCLUDE_DIR
cargo:rerun-if-env-changed=OPENSSL_DIR
run pkg_config fail: "`\"pkg-config\" \"--libs\" \"--cflags\" \"openssl\"` did not exit successfully: exit code: 1\n--- stderr\nPackage openssl was not found in the pkg-config search path.\nPerhaps you should add the directory containing `openssl.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'openssl\' found\n"
--- stderr
thread 'main' panicked at '
Could not find directory of OpenSSL installation, and this `-sys` crate cannot
proceed without this knowledge. If OpenSSL is installed and this crate had
trouble finding it, you can set the `OPENSSL_DIR` environment variable for the
compilation process.
If you're in a situation where you think the directory *should* be found
automatically, please open a bug at https://github.com/sfackler/rust-openssl
and include information about your system as well as this message.
$HOST = x86_64-unknown-linux-gnu
$TARGET = x86_64-unknown-linux-gnu
openssl-sys = 0.9.15
', /home/username/.cargo/registry/src/github.com-1ecc6299db9ec823/openssl-sys-0.9.15/build.rs:198
note: Run with `RUST_BACKTRACE=1` for a backtrace.
Build failed, waiting for other jobs to finish...
error: build failedWhat do I need OpenSSL for? |
This comment has been minimized.
This comment has been minimized.
|
openssl-sys (ffi wrapper over system OpenSSL) is a build predicate for hyper and reqwest that are used in some other examples. Basically you need to install OpenSSL developement package as described in |
This comment has been minimized.
This comment has been minimized.
|
Alright now I can run the tests, thanks @budziq. I changed the example to use a hardcoded query. It works well but the test still fails:
fn run() -> Result<()> {
let query = "CA";
let data = "\
City,State,Population,Latitude,Longitude
Kenai,AK,7610,60.5544444,-151.2583333
Oakman,AL,,33.7133333,-87.3886111
Sandfort,AL,,32.3380556,-85.2233333
West Hollywood,CA,37031,34.0900000,-118.3608333";
let mut rdr = csv::ReaderBuilder::new().from_reader(data.as_bytes());
let mut wtr = csv::Writer::from_writer(io::stdout());
wtr.write_record(rdr.headers()?)?;
for result in rdr.records() {
let record = result?;
if record.iter().any(|field| field == jjjjkkkjjjquery) {
wtr.write_record(&record)?;
}
}
wtr.flush()?;
Ok(())
} |
This comment has been minimized.
This comment has been minimized.
|
Hi I see two problems:
error[E0425]: cannot find value `jjjjkkkjjjquery` in this scope
--> src/main.rs:30:47
|
30 | if record.iter().any(|field| field == jjjjkkkjjjquery) {
| ^^^^^^^^^^^^^^^ not found in this scopePlease update the PR with newest code and if the problems persist I'll look at the problem :) |
bsotodo
force-pushed the
bsotodo:ex-csv-filter
branch
from
683c8de
to
f03dab7
Aug 11, 2017
budziq
requested changes
Aug 16, 2017
|
@sotocodes sorry for the delay. I do not get notifications when new commit arrives. Only after comments in the PR thread. So please ping me next time :) The code looks great. but there are some minor suggestions to the description: |
|
|
||
| _Disclaimer: this example is modified version of [this](https://docs.rs/csv/*/csv/tutorial/index.html#filter-by-search) one._ | ||
|
|
||
| Takes a `query` from the command line as input and outputs only the |
This comment has been minimized.
This comment has been minimized.
budziq
Aug 16, 2017
Collaborator
Takes a
queryfrom the command line as input and outputs only the
well its not true anymore ;)
This comment has been minimized.
This comment has been minimized.
|
|
||
| [![csv-badge]][csv] [![cat-encoding-badge]][cat-encoding] | ||
|
|
||
| _Disclaimer: this example is modified version of [this](https://docs.rs/csv/*/csv/tutorial/index.html#filter-by-search) one._ |
This comment has been minimized.
This comment has been minimized.
budziq
Aug 16, 2017
Collaborator
I would move the disclaimer to bottom of the text or example and reword the text to:
"Disclaimer: this example has been adapted from the csv crate tutorial ."
bsotodo
force-pushed the
bsotodo:ex-csv-filter
branch
from
f03dab7
to
bdd2697
Aug 22, 2017
This comment has been minimized.
This comment has been minimized.
|
Hey @budziq, I made the changes but it seems that AppVeyor does not like them :)
roger that! |
bsotodo
closed this
Aug 22, 2017
bsotodo
reopened this
Aug 22, 2017
This comment has been minimized.
This comment has been minimized.
|
nicely done! |
budziq
merged commit 588e7cb
into
rust-lang-nursery:master
Aug 22, 2017
This comment has been minimized.
This comment has been minimized.
|
thanks for the help :) |
This comment has been minimized.
This comment has been minimized.
|
no problem. keep 'em coming :) |
bsotodo commentedAug 8, 2017
Resolves #230