WordPress Export table as csv using Ajax

Hello guys i'm trying to export my plugin table in the same page, i tried to do hidden iframe but it's still not works, can you kindly check my code please? thanks. PHP: add_action( "wp_ajax_export_plugin", "export_plugin" ); //update_records is action add_action( "wp_ajax_nopriv_export_plugin", "export_plugin" ); function export_plugin(){ global $wpdb; $wpdb->show_errors = TRUE; $wpdb->suppress_errors = FALSE; $plugin_name = $_POST['plugin-name']; // PLUGIN NAME $plugin_export_type = $_POST['export-type']; // PLUGIN EXPORT TYPE as CVS/SQL/XML $plugin_name; // ?? not defined in original code $results = $wpdb->get_results("SELECT …
Category: Web

WordPress CSV Importer takes a long time to finish

I have created a lot of custom CSV importers for WordPress in the past and I have come across issues related to the time it takes for them to finish processing. Whenever the importer starts running, it starts off importing a lot of posts per second but this speed keeps decreasing and I am trying to figure out the reason for this and if whether there is something that I can do to speed up things. Some importers I create …
Category: Web

Product CSV import problems with certain html tags

I'm transferring all of my WooCommerce products from one installation to another just by simply exporting the products to CSV and importing them again. Initially, the import would not work and the error message: Sorry, you are not allowed to upload this file type. This was a bit of a surprise as it was just an export csv file from another WooCommerce site. So I downloaded a sample csv import file and this worked fine. To cut a long story …
Category: Web

Whole time column in csv file convert into UTC (epoch) using python

I have a dataset with time and columns. I want to plot a graph with time and value. I tried many methods but didn't come proper graph. Because I have a time series. Then I thought I will convert time into UTC then try to plot it. But I didn't have any idea how to convert the whole column into UTC. Can anyone help me to solve this error? time.strftime("%Y-%m-%d %H:%M:%S", time.gmtime(time.mktime(time.strptime("2008-09-17 14:04:00", "%Y-%m-%d %H:%M:%S")))) This code is for only …
Category: Data Science

The single CSV created by combining a large number of CSV files is too large to process. What options do I have?

The dataset I am currently working on has more than 100 csv files, with each of size more than 250MB. These are files containing time series data captured from different locations and all the files have the same features as columns. As I understand, I must combine these into one single csv file to use these data in a CNN, RNN or any other network and its assumed to be more than 20GB after completion. But this is an unacceptable …
Category: Data Science

Export to csv adding html to file

I am trying to export results to a csv file using the following code. The export appears to work, but when I open the file, it contains the html code from the page. Any help is appreciated. ob_start(); global $wpdb; $domain = $_SERVER['SERVER_NAME']; $table = $wpdb->prefix . "qi_project_requests"; $filename = "export.csv"; $sql = $wpdb->get_results("select * from $table"); $header_row = array( 'Date Submitted', 'Requestor Name' ); $data_rows = array(); foreach ($sql as $data) { $row = array( $data->date, $data->rname ); $data_rows[] …
Category: Web

Has anyone joined FHIR resources?

I have FHIR-formatted data (Fast Healthcare Interoperability Resources), that I've converted to CSV using the npm package ndjson-to-csv, and on first glance, this seems useable for ML experimentation, as long as I first join the data on the relevant properties. I could spend a while going through the approximately 12 resource types (like Device, Patient, Condition, etc) to see which resource types are joinable and if so on what property. However, I was wondering if anyone has a cheat sheet …
Category: Data Science

Efficiently modify a large csv file in Pandas

I have a csv file and would like to do the following modification on it: df = pandas.read_csv('some_file.csv') df.index = df.index.map(lambda x: x[:-1]) df.to_csv('some_file.csv') This takes the index, removes the last character, and then saves it again. I have multiple problems with this solution since my csv is quite large (around 500GB). First of all, reading and then writing seems not to be very efficient since every line will be fully overwritten, which is not necessary, right? Furthermore, due to …
Category: Data Science

multiple images inside one large CSV file

I'm very new to data science, and was admiring how people had made these massive open-source datasets, on places like kaggle. I noticed that all of the datasets where all in CSV format. I have lots of images that I'd like to upload to kaggle for everyone to use, although don't know how to convert my images to CSV. (I can't upload them as individual images because there is a limit of 1000 files, which is not enough for a …
Category: Data Science

How to download CSV from sub directory in uploads folder

hello guys i donot have experience working with the csv. I have a very big form i wanted to make a custom csv export for this form and a new csv is generated every time the form is submited. i am using gravity form and gravity form gform_post_submissiom hook to capture the entry. Everything is working fine until this point. I have created a sub dir in uploads folder. Csv for every entry is being created in this folder. I …
Category: Web

Importing CSV into database table not working?

global $wpdb; if (isset($_POST["import"])) { $fileName = $_FILES["file"]["tmp_name"]; if ($_FILES["file"]["size"] > 0) { $file = fopen($fileName, "r"); while (($column = fgetcsv($file, 10000, ",")) !== FALSE) { $table_name = 'sas' ; $wpdb->insert( $table_name, array( 'category' => '" . $column[0] . "', 'temple' => '" . $column[0] . "' ) ); } } } I want to import csv directly into the core wordpress database table 'sas' .The csv contains some records with the structure of the table i have created...But the …
Category: Web

Extract or subset hundreds of columns from a data frame

I need to extract many columns from a dataset. I have a very large csv file with thousands of columns and rows, and I read it into R using: mydata <- read.csv(file = "file.csv",header = TRUE,sep = ",",row.names = 1) Each column is a gene name. I know how to extract specific columns from my R data.frame by using the basic code like this: dataset[ , "GeneName1", "GeneName2"] But my question is, how do I pull hundreds of gene names? …
Topic: csv r
Category: Data Science

How do I get data from my database into my Custom Export Field

I am trying to get data from my database to export to a XML or CSV File by using a custom query. This is my function with the query : <?php function get_workhours($ID){ $sql = $wpdb->prepare("SELECT worked_hours FROM db_info WHERE job_id = $ID"); $data = $wpdb->query($sql); if(empty($data)){ return "0"; }else{ return $data; } ?> And in my custom export field i have this : [get_workhours{ID}] And when I try to preview this it gives me the error : An unknown …
Category: Web

How to store strings in CSV with new line characters?

My question is: what are ways I can store strings in a CSV that contain newline characters (i.e. \n), where each data point is in one line? Sample data This is a sample of the data I have: data = [ ['some text in one line', 1], ['text with\nnew line character', 0], ['another new\nline character', 1] ] Target CSV I want a CSV file, where the first line is "text,category" and every subsequent line is an entry from data. What …
Category: Data Science

Exporting a form to a CSV file does not work in WordPress but it does in PHP

I have a form with some fields that I need to implement in a WordPress template. If I do it in vanilla PHP it works but when I put it in a WordPress template it doesn't work, can it be a problem with $_POST? <?php /** * Template Name: Telesales */ ?> <?php if(isset($_POST['submit'])){ $firstName = $_POST['firstName']; $lastName = $_POST['lastName']; $DOFMonth = $_POST['DOFMonth']; $DOFDay = $_POST['DOFDay']; $DOFYear = $_POST['DOFYear']; $Content = "Name,LastName,Birthday\n"; $Content .= "$firstName,$lastName,$DOFMonth-$DOFDay-$DOFYear\n"; $FileName = $firstName."-".date("d-m-y-h:i:s").".csv"; header('Content-Type: application/csv'); …
Category: Web

How to export custom database data to excel file

Hi everyone I have the code below, but when I click on the link generated a new page is open with 0 display on it. What I'm doing wrong? function list_reservation_to_csv() { global $wpdb; $table_name = $wpdb->prefix . 'prenotazione_eventi'; $file = 'email_csv'; // ?? not defined in original code $results = $wpdb->get_results("SELECT * FROM $table_name",ARRAY_A); if (empty($results)) { return; } $csv_output = '"'.implode('";"',array_keys($results[0])).'";'."\n";; foreach ($results as $row) { $csv_output .= '"'.implode('";"',$row).'";'."\n"; } $csv_output .= "\n"; $filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); …
Category: Web

How to Analyze Blocks and find Intersection and patterns between pages

What is the best way to analyze existing site fully built on Gutenberg Blocks and inspect intersection of existing blocks structure and it’s inner blocks combination for all pages? Context: Imagine that instance have: ~100 landing pages and СPTs(not just blog posts) that built using core block, custom and some vendor blocks. each page using about 150 blocks (according on Query Monitor -> Blocks counter) no components at all: there are a huge blocks fragmentation in components/layouts, like you are …
Category: Web

Convert .data file to .csv

I'm using a data called 'adults.data', I need to work with that data as a '.csv' file. Can anyone guide me on how can I change the format? I tried opening the file in excel and then save it as csv, but the new file contains only one column containing all the '.data' columns.
Topic: data csv dataset
Category: Data Science

Error: `raise ValueError( ValueError: Missing column provided to 'parse_dates': 'Date'

I am using a .csv with two columns. The first has dates and the second has temperatures. I would like to plot it with dates on the x-axis and temperatures on the y-axis. I used this command: dataset = pandas.read_csv('/home/UbuntuUser/Desktop/mesurements.csv', usecols=[1], engine='python', skipfooter=3, index_col=['Date'], parse_dates=['Date']) but I got the error: Error: raise ValueError( ValueError: Missing column provided to 'parse_dates': 'Date' Any ideas why? From searching, I found this suggestion, that does not help me. Update: Part of the code is …
Topic: csv pandas python
Category: Data Science

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.