How to import data from an xml file into cassandra directly
Tag : java , By : Michael
Date : March 29 2020, 07:55 AM
wish of those help I think your connection is got broken after processing some data. I faced such issue once & solved that by using connection pooling. Can you tell me how you are getting the connection in your java code ?
|
Is there a way to import csv file from Cassandra DevCenter?
Date : March 29 2020, 07:55 AM
I hope this helps you . One way to import csv file is by using copy command in cqlsh. I am wondering is there an effective way to import csv file from DevCenter ? , Sorry, there currently is no way to import from CSV using DevCenter.
|
Sqoop import into Cassandra fails on cassandra parameters
Tag : mysql , By : Hibame
Date : March 29 2020, 07:55 AM
I wish this helpful for you The commands changed post DSE 4.7. The correct command for doing a thrift import should be: ./dse sqoop thrift-import --connect jdbc:mysql://10.0.0.20/amad \
--username root \
--table aminno_mem_email \
--cassandra-keyspace am_cc \
--cassandra-table am_cc_cf \
--cassandra-row-key am_cc_key \
--cassandra-host 10.0.0.13 \
--cassandra-create-schema
|
how to import csv file to cassandra
Date : March 29 2020, 07:55 AM
this one helps. Cassandra doesn't preserve the order of column when creating. You need to specify the column name when importing data. Try this command : COPY consumer_complaints (Date_received,Product,Sub_product, Issue, Sub_issue, Consumer_complaint_narrative, Company_public_response, Company, State, ZIP_code, Tags, Consumer_consent_provided, Submitted_via, Date_sent_to_company, Company_response_to_consumer, Timely_response, Consumer_disputed, Complaint_ID) FROM 'c.csv' WITH HEADER = true;
Date_received,Product,Sub_product, Issue, Sub_issue, Consumer_complaint_narrative, Company_public_response, Company, State, ZIP_code, Tags, Consumer_consent_provided, Submitted_via, Date_sent_to_company, Company_response_to_consumer, Timely_response, Consumer_disputed, Complaint_ID
07/26/2013,Mortgage,FHA mortgage,"Loan servicing, payments, escrow account",,,,"CITIBANK, N.A.",NC,28056,,N/A,Web,07/29/2013,Closed with explanation,Yes,No,467750
09/26/2014,Consumer Loan,Vehicle loan,Managing the loan or lease,,,,HSBC NORTH AMERICA HOLDINGS INC.,NY,12572,,N/A,Web,09/26/2014,Closed with explanation,Yes,No,1046323
complaint_id | company | company_public_response | company_response_to_consumer | consumer_complaint_narrative | consumer_consent_provided | consumer_disputed | date_received | date_sent_to_company | issue | product | state | sub_issue | sub_product | submitted_via | tags | timely_response | zip_code
--------------+----------------------------------+-------------------------+------------------------------+------------------------------+---------------------------+-------------------+---------------+----------------------+------------------------------------------+---------------+-------+-----------+--------------+---------------+------+-----------------+----------
1046323 | HSBC NORTH AMERICA HOLDINGS INC. | null | Closed with explanation | null | N/A | No | 09/26/2014 | 09/26/2014 | Managing the loan or lease | Consumer Loan | NY | null | Vehicle loan | Web | null | Yes | 12572
467750 | CITIBANK, N.A. | null | Closed with explanation | null | N/A | No | 07/26/2013 | 07/29/2013 | Loan servicing, payments, escrow account | Mortgage | NC | null | FHA mortgage | Web | null | Yes | 28056
|
Import csv file in cassandra using python script
Date : March 29 2020, 07:55 AM
With these it helps You're on the right path. The only things you need to add, is a file reader (I saved your data as a .csv file and got it to work), a for-loop to iterate through it, and then an import of the datetime package to convert your dates for the prepared statement. This worked for me: with open("/home/aaron/Documents/stackoverflow/test_NYC_taxi.csv", "r") as fares:
for fare in fares:
columns=fare.split(",")
pickup=datetime.datetime.strptime(columns[0],"%Y-%m-%d").date()
dropoff=datetime.datetime.strptime(columns[1],"%Y-%m-%d").date()
distance=columns[2]
fare=columns[3]
p_long=columns[4]
p_lat=columns[5]
d_long=columns[6]
d_lat=columns[7]
session.execute(prepared, [pickup,dropoff,distance,fare,p_long,p_lat,d_long,d_lat])
#closing the file
fares.close()
#closing Cassandra connection
session.shutdown()
|