mine .csv file is not uploading? - csv

i am using this condition to check my uploaded csv file.
$_FILES['csv_file']['type'] == "application/octet-stream"
||
$_FILES['csv_file']['type'] == "text/plain"
even-though i am uploading csv file it show error i.e my csv file not uploading...

hey, did you checked the webserver has permissions to upload files to the directory your are trying to upload?
maybe a bit more of code will help here..

Related

How do I get my file to be saved as JSON after writing a JSON file into AWS S3 bucket

I am trying to write a JSON file into my AWS S3 bucket. However, I do not get a JSON file after it has been uploaded.
I get my data from a website using a request.get() and format it into a JSON file which I then run the following script to upload it to me S3 bucket.
r = requests.get(url=id_url, params=params)
data = r.json()
s3_client.put_object(
Body=json.dumps(data, indent=3),
Bucket='bucket-name',
Key=fileName
)
However, I am not sure what the type of file is but it is supposed to be saved as a JSON file.
Screenshot of my S3 bucket having no file type
Screenshot of my download folder, showing unable to identify the file type
When I open the file by selecting Pycharm, it is just a dictionary with key and values
Solved it, I simply added ".JSON" to the filename and it has solved the file formatting issue. Dont know why I didnt think of this earlier.
Thank you
Ideally you shouldn't rely of file extensions to specify the content type. The put_object method supports specifying ContentType. This means that you can use any file name you like, without needing to specify .json.
e.g.
s3_client.put_object(
Body=json.dumps(data, indent=3),
Bucket='bucket-name',
Key=fileName,
ContentType='application/json'
)

Importing a file to a web page [SELENIUM]

I am creating a selenium script to automatically log in to a webpage, and then import a .xls file. However I am stuck in the part when the webpage prompts me to select a file from my computer. How do I code to send the keys with the file path and press "enter"? Thanks in advance!
To upload a file with Selenium you can send the file's path to input element with type file on the web page.
If, for example your file path is C:\your_file.xls your code will be something like this:
file_path = 'C:\your_file.xls'
upload_input = driver.find_element_by_xpath('//input[#type="file"]')
upload_input.send_keys(file_path)

LOAD CSV command keeps using old file: location, ignores command input

I am using Community edition 3.0.5 on Windows 10 . I made multiple efforts to execute a LOAD CSV command before being told that such files cannot reside on an external drive. When I moved the file to users/user/ and tried to execute the LOAD CSV command I got the same message "Couldn't load the external resource at: file:/F:/Neo4j%20DBs/Data.gov%20Consumer%20Complaints/Consumer%20Complaints%20DB/import/Users/CharlieOh/Consumer_Complaints.csv" in spite of the fact the command I entered was
"LOAD CSV WITH HEADERS FROM
'file:///Users/CharlieOh/Consumer_Complaints.csv' AS line
WITH line
LIMIT 1
RETURN line"
I tried to locate the file neo4j.conf and could only find C:\Program Files (x86)\Neo4j Community 3.2.2\Neo4j Community.install4j\i4jparams.conf . I even deleted the old DB and recreated the small amount of data and got the same error, which seems to indicate that the LOAD CSV function is totally useless across all my neo4j databases. BTW the %20 in the file specification was due to suggestions on Stack Overflow as well as using underscores to avoid any use of blank spaces in the file specification. None of it worked and now that I believe that I may have solved the problem by putting the csv file in the user directory, the LOAD CSV function won't let me do it. One last thing, I am following the YouTube video https://www.youtube.com/watch?v=Eh_79goBRUk to learn how to load a csv file into neo4j.
The csv file needs to go in the import directory of the specific database. With Neo4j Desktop this is easy to identify by clicking on the Manage button of the database and then the open folder button. It looks like you've found it.
Once the database import directory is located, you specify it in the LOAD CSV with the statement LOAD CSV WITH HEADERS FROM 'file:///" + FN + "'where FN is your file name, including the csv extension. You do NOT use the full path; that is assumed.

problam wuth Uploading csv file

I'm trying to upload a csv file to R and when I do its write this messege:
this is the scv file , Itried to upload the file, but I don't know if I can here,

Chrome file upload not recognising accept mimetype 'text/csv'

I'm trying to limit the files shown in the pop-up file selector when using chrome to just csv files (I would settle for just text files including csvs).
I have tried the following accept options:
text/csv; All files shown
text/comma-separated-values; All files shown
application/csv; All files shown
application/excel; All files shown
application/vnd.ms-excel; 97-03 Excel workbooks, but no csvs
text/*; Some text files shown, but no csvs
application/*; Some application files shown, but no csvs
Am I missing something?
The solution is simple, although not very intuitive given the other mime types.
Just use .csv and Chrome will filter your files properly.