How do I import issues and articles from spreadsheet?

import

#14

@ajnyga,

thank you very much! I’d give this a try.

Tobias


#15

This is absolutely brilliant, @ajnyga. Thank you so much!

I get this error, though, when I try to create an xml-file (I have used your example-spreadsheet for testing, only changing file names to test upload of my own pdf’s):

Fatal error: Call to undefined function mime_content_type() in .../convert.php on line 258

Do you have any idea what this might be caused by?


#16

Hi, seems to be related to a missing php extension, see https://stackoverflow.com/questions/14809054/mime-content-type-function-not-working

edit: hmm, the function seems to be deprecated, I have to check if I could replace it with something.’

edit edit: or is it, what is your PHP version?


#17

Thank you for helping! My php-version is 4.7.3.

edit: No, that was the phpMyAdmin version. The php-version is 5.6.30.


#18

I am finding very mixed information on whether the function is deprecated or not.

Your could try enabling the mime_magic extension in php. If that does not work for you, you could try adding this function to the converter file.

function _mime_content_type($filename) {
    $result = new finfo();

    if (is_resource($result) === true) {
        return $result->file($filename, FILEINFO_MIME_TYPE);
    }

    return false;
}

#19

Hi all,

The mime_content_type function wasn’t deprecated, then it was, now it isn’t again.

The good news is that PKP software only uses it as a fallback when the “preferred” mechanism, the fileinfo suite of tools, isn’t available. See Error message on upload: “No file uploaded or invalid file type!” for more information about how OJS/OMP/etc. determine file types.

Regards,
Alec Smecher
Public Knowledge Project Team


Import a lot of journals
#20

Thanks, I’ve tried both without luck unfortunately. Maybe I could find / set up a server with an older version of php…


#21

Hi @troelsk,

The most recent releases of OJS require PHP5.6 at least, and my dev environment runs on PHP5.6 without problems. If you’re changing your PHP module configuration, have you restarted your web server afterwards?

Regards,
Alec Smecher
Public Knowledge Project Team


#23

I’ve now managed to run your script on a php-server with version 7.0. Unfortunately, I just get another type of error, for some reason. What php version did you use originally, @ajnyga?

Fatal error: Uncaught Error: Class 'ZipArchive' not found in /home/isbuddet/public_html/troelskolln/ojs/tsvconverter/phpexcel/Classes/PHPExcel/Reader/Excel2007.php:94 Stack trace: #0 /home/isbuddet/public_html/troelskolln/ojs/tsvconverter/phpexcel/Classes/PHPExcel/IOFactory.php(268): PHPExcel_Reader_Excel2007->canRead('eksempel.xlsx') #1 /home/isbuddet/public_html/troelskolln/ojs/tsvconverter/convert.php(60): PHPExcel_IOFactory::createReaderForFile('eksempel.xlsx') #2 {main} thrown in /home/isbuddet/public_html/troelskolln/ojs/tsvconverter/phpexcel/Classes/PHPExcel/Reader/Excel2007.php on line 94

#24

Hi @troelsk,

See e.g. https://stackoverflow.com/questions/3872555/fatal-error-class-ziparchive-not-found-in for instructions on installing ZipArchive support. It’s available for all modern PHPs.

Regards,
Alec Smecher
Public Knowledge Project Team


#25

Hi @asmecher. Well, I don’t really need OJS to be running for this, I just need to get the xml-files created, so that’s not a concern for me. But thanks for the tip about restarting the server.


#26

Hi,
I used PHP 5.6, but it should work with PHP 7 as well. The problems you are experiencing are related to missing PHP extensions Alec also refererred to:
php_zip
php_xml
php_gd2

The PHPexcel library does mention that the zip extension is only needed if you use it with xlsx-files. So maybe you could test if a .xls files works?


#27

Thank you again (also to @asmecher)!

All the extensions should now be installed on a php 7.0 installation. I’ve also tried with an .xls-file. However, I now a get a similar, but slighly different error 10 lines later.

Fatal error: Uncaught Error: Call to undefined function mime_content_type() in /home/isbuddet/public_html/troelskolln/ojs/tsvconverter/convert.php:268 Stack trace: #0 {main} thrown in /home/isbuddet/public_html/troelskolln/ojs/tsvconverter/convert.php on line 268

Btw, I completely understand if you don’t have time to go through all this. I am very grateful, though. This is by far the closest I’ve been to a solution so far!

Oh, and here is a photo of my php-installation (via cPanel):


#28

Hi,

You could try enabling fileinfo extension there and add the custom function I pasted in my earlier post?

Or, as second alternative, try to enable the mime_magic extension in cPanel. I have no good idea how you would do this, because I do not use cPanel myself.


#29

HALLELUJA! It works. Thank you so much :slight_smile:

Now I just need to test the xml-file, and for some reason my OJS-installation is now broken, but that should be easy to fix (I get the error that I need to use a php version less than 7).


#30

With PHP7, you probably need switch using mysqli. You can search the forum for details.

You can also try going back to PHP5 and enabling the fileinfo extension (and other needed extensions) with that version.


#31

That works, thanks. So the xml-file gives me this error:

Element '{http://pkp.sfu.ca}affiliation': This element is not expected. Expected is one of ( {http://pkp.sfu.ca}url, {http://pkp.sfu.ca}orcid, {http://pkp.sfu.ca}biography ).

Seems to me like it doesn’t recognise that element. Actually, I don’t even need have that data to upload, so I guess I could just remove it from the script.


#32

Can you show me what the data looks like (you can send the xls to ajnyga@gmail.com) if you do not want to show it here.

And, what OJS version are you importing to. I only used 3.0.2. so it could be that something changed recently in OJS XML.


#33

Actually probably the easiest would be, if you would send me the XML file. I have imported authors with affiliations, but you perhaps have a combination of data that I have not had.

The author element in your XML should look like this. Does your element look different? Do you for example have multiple affiliation elements there?

    <author primary_contact="true" include_in_browse="true" user_group_ref="Author">
      <firstname>XXXXXX</firstname>
      <lastname>XXXXXX</lastname>
      <affiliation locale="en_US">XXXXXX</affiliation>
      <country>XXXXXX</country>
      <email>XXXXXXX</email>
      <biography locale="en_US">XXXXXX</biography>
    </author>

Edit: I made a new release of the script: https://github.com/ajnyga/tsvConverter/releases
It should now check for the two alternative ways for mime type and I also changed the way the script handles localized affiliations. Not sure if it helps in your problem, but you could give it a try.


#34

First of all: amazing help, thanks!

Second: I have attached the xml-file. It returns the same error in both your versions of the script (when uploading to OJS, that is).

The spreadsheet I use is based on your sample, with only the file names of the pdf’s changed (to test my own files). You can see the xml-file here and the spreadsheet here.

When I manually remove the affiliation tag from the xml-file, it seems to upload correctly to OJS - but I get the error “Unknown uploader admin”. That might be something to do with the setup of my OJS test site.

Edit: I am importing into OJS 3.1.0.1.