How to partially read a CSV file with Super CSV - csv

I have a csv file with 24 columns. Out of these I only want to read 3 columns. I see that super CSV is a very powerful library, but I can't figure out how to partially read a CSV. The link that have on partial reading is broken.
Please do help me out with a working example.

Update: SourceForge is back online! The Super CSV site should work now :)
That's the correct link, but SourceForge project websites are down right now (according to the SourceForge blog):
Starting at 12:59 UTC today, we experienced a site outage, causing
general connectivity issues sitewide. At 15:12 UTC, site connectivity
was restored and most services, including downloads, are now back
online. Some services are however are offline while we continue to
diagnose and determine the root cause for this issue. The services
still offline are:
Project web (ie., projectname.sourceforge.net pages) and associated
shell and database services. This also includes access through sftp,
scp, and rsync via ssh.
So you have a few options:
view the source code of the reading example on SourceForge (this part of SF is still working). There's a link to download the file at the top left.
check out the project source from subversion (you can view/run the reading example listed above to see how it works, or you can even run mvn site:site to generate the project website locally
view the cached page from Google
I hope you enjoy using Super CSV - if you have any other questions feel free to post them here on SO, or on the project help forum on SourceForge.

Related

MediaWiki update from 1.15 to latest version

Would it be possible to upgrade from MediaWiki from 1.15 to the latest stable version without losing data? I believe I will have a problem with database tables and extensions.
Thank you in advance
From personal experience I would recommend to take it easy and upgrade one major version at a time, especially when you do not have much experience with the process. This bite size approach will take longer but in return you will:
have to deal with fewer issues every time something is not right,
gradually update the LocalSettings.php as you go along every time moving it from the current to new release,
familiarise yourself with the Release Notes for each version - they contain notes on the configuration and breaking changes among other things, and finally
get comfortable with the process.
This approach helped me when I was upgrading from 1.27.3 to 1.31.8 first time in years. I came across problems at least twice and could not find relevant information on how to deal with them. The most annoying was no feedback from the update.php script or blank page when trying the new installation.
Below I include notes from my experience with updating MediaWiki in case that's of any help to anyone facing a big upgrade. These are just main points, so read the official Upgrading page too.
Installation
Don't extract a MediaWiki release archive into the existing wiki installation directory. Move the old instance to some backup directory and start afresh. Also make a back-up of the database.
Create a copy of LocalSettings.php from the original installation and comment out all custom extensions and skins as they will no longer be present.
Now as you bump the versions up:
Copy LocalSettings.php from the previous instance to the directory created while extracting a release archive. There does not seem to be a way to generate a fresh default LocalSettings.php during an upgrade, which would prevent some of the problems.
Run update script in the maintenance directory. There should be some output:
$ php update.php
MediaWiki 1.31.8 Updater
...
If there is no output at all that means there is likely a problem somewhere in the LocalSettings.php configuration. See the Debugging section below.
You should be able to access the wiki now.
Get a release archive of the next major version, read the Release Notes and repeat the steps.
Once you reached the target version you can gradually copy over all the custom changes from the old wiki (extensions, modifications, images, skins etc.) remembering to enable them in LocalSettings.php.
Keeping MediaWiki under version control makes it much easier to keep track of any customisations. Just make sure you keep the repository inaccessible to the world.
Debugging
In order to debug enable the following settings in LocalSettings.php:
$wgShowExceptionDetails = true;
$wgShowDBErrorBacktrace = true;
$wgShowSQLErrors = true;
Now go to the installation page https://.../mw-config/ (adjust the URL to match your set-up) and you should see some errors that might indicate what is wrong. For example, some skins or extensions from the older version may not supported any longer and you have to disable them in LocalSettings.php.
Once the configuration has been updated try again until you get to the web installer.
Once you managed to get to the web installer page stop there and try again with update.php script. It should work now. Close the web installer, there won't be any need to run it now.
Once update.php has finished you should be able to access the wiki. Disable the debug settings in LocalSettings.php.
In theory, yes - the update mechanism is a big array of database migration scripts, which gets expanded when you upgrade the code, so the number of versions doesn't really matter. In practice, that's a long way to go, so it's very unlikely anyone else has tested that specific upgrade path. Make sure to backup first.
One notable exception is HitCounter data, which does get dropped, as that functionality was removed from MediaWiki. See that page for workarounds.

Website hack line appearing on wordpress homepage

Helping a friend's company with their website. They have a random bit of code appearing on a bar near the top of what looks to be just on the homepage:
http://snakeoilcocktail.com/
The line is here according to the source:
<div class='dc'>You take that to bank:same day loans. Buy there a atv armor set</div>
I used a plugin to do a String check to find out where the line is but I can't see where it's located to edit it. Any help would be greatly appreciated.
Thanks!
Looks like there's some malware injected on the site. In the top navigation under "Beverage Catering and Event Mixology" there's what looks like some malicious JS code that's adding a div with a class of "dc". Not sure what your setup is, but I'd advise checking into this plugin: https://wordpress.org/plugins/sucuri-scanner/
It'll tell you if any of the core Wordpress files have been hacked, or if it recognizes any files that aren't part of WP.
They have a free quick scanner, check this out: https://sitecheck.sucuri.net/results/snakeoilcocktail.com/
Revolution Slider is a big risk :) (Note the comment on Sucuri) It's supposedly been patched but they ran into a huge security issue where thousands of WP sites were infected. Happened to a couple of sites I took over as well - I completely removed it.
In other words, if you have to keep the Revolution Slider plugin, update it ASAP. It introduces a vulnerability that allows hackers to upload arbitrary files to your site - bad news. They often upload something that gives them read access to the wp-config.php file so they can get into the database as well. (http://securityaffairs.co/wordpress/35431/cyber-crime/revslider-plugin-vulnerable.html)
It has to be somewhere! So either one of your plugins is outputting that code or it has been hacked into your theme.
First, try to deactivate all the plugins one after each other to find out if a plugin causes that issue. If that doesn't help, you may need to go through each file in the theme until you found the target. Also notice that the code could look different in a file than the code which you have posted in your question.
Your website must gave been infected with a malware/adware of some sort. This usually happens when you are using a free hosting service. Check whether your friend is using a free hosting service to host his website. Some of those providers inject advertising content into free hosted websites to make revenue.
If this is not the case,
Restore to previous backup
Disable any plug-ins used on the website
Check through the code for any suspicious lines.
Delete all the files on the web server if possible and try re-uploading
the source files.
Migrate to a hosting provider such as goDaddy, AWS etc for security of
your website.

Which server os to use for small office with very limited requirements

We are currently moving to a new office. We currently use a combination of OneDrive and GoogleDrive to store all of our photography and shared folders however the new premises are not fibre ready so I do not want to use all the bandwidth on uploading / downloading photos. Therefore we require a really basic server.
I need the server to hold all images and shared files, then after 5pm open up OneDrive and GoogleDrive to begin the synch (whilst everyone is out of the office) then close those programs down before 7am the next morning.
Could anyone recommend a Server OS that would allow me to do this quite easily, it's the only requirement we have for the server.
I've heard that freeNas or Ubuntu may be a good way to go but have no experience with any.
I know this question isn't very specific to one language etc. however I'm not sure where else to ask it, so if anyone has any information on better places to post the question then I'd be really greatfull for that to.
Thank you
Glynn
I think most server OS'es should be able to fulfil your needs. If you want convenience, then I would suggest Ubuntu server. It's very easy to setup, compatible with most hardware and lots of documentation available on the interwebs. For your file sharing needs: I would suggest checking out Bittorrent Sync. It's really nice!

simple way to quickly edit my website

here's my website:
www.newportclassic.com
do you know of any free, easy to use, content management systems, that will allow me to simply edit the text on my site without having to download the file, open the file, edit the code, save the file, upload the file ???????
I know of a few CMS's that have done well, here are two of them.
Wordpress - free - http://wordpress.org/ - 3.0 is coming soon
Perch - paid - http://grabaperch.com/ - very light and easy
Wikipedia has a very good list of content management systems broken down by language and cost (open source/proprietary) and DBMS. Most of the ones I've used/evaluated in the past have been .NET based, such as DotNetNuke. Pretty much any CMS will give you the ability to edit your HTML without changing any files on your web server. If you're going for simplicity, the Wikipedia list has several that use a flat file instead of a database, so I would start there: http://en.wikipedia.org/wiki/List_of_content_management_systems#File_.2F_Flat_file
As an alternative to installing a CMS on your server, you might be interested in a service like CushyCMS. It allows you to specify what parts of your page are editable by setting an appropriate class in each editable div tag. Then to edit the contents of those div blocks, you log in to the CushyCMS site and make your changes right there. CushyCMS connects via FTP to the server for you and updates the HTML page.
You can use emacs -- it has a mode (tramp) where you can open, edit and save remote files as if they were on your local machine. This makes it really easy to edit files on a webserver.
haven't used it myself but i've heard Surreal CMS is quite good and easy to setup. Here's a tutorial to get you started.
In terms of user friendliness zimplit is hard to beat.
Try their demo.
You can literally edit your website with a wysiwyg interface inside your browser.
Refinery HQ is probably the easiest way to create, edit and update your website. You can upload images and files as you describe in your question.
You can also connect it to your own domain (it's a hosted service). So you'd be able to hook the site you create up to newportclassic.com

Better interface for file downloads and uploads from a web page?

I have what seems like a typical usage scenario for users downloading, editing and uploading a document from a web page.
User clicks a link to download a document
User edits downloaded file
User saves the file
User goes back to the web page and uploads the new file with the changes
The problem is that downloaded files are typically saved in a temporary directory, so it can be difficult to find the file after it is saved. The application is for very non-technical users, and I can already imagine the problems with saved files being lost or the wrong versions being uploaded.
Is there a better way? Things I've thought about:
Using Google Docs or something similar.
Problems: forcing users to use new
application with less features,
importing legacy content, setting up
accounts for everyone to edit a
file.
Using WebDAV to serve the files. Not sure how this would work exactly, but seems like it should be possible
Some kind of Flash or Java app that manages downloads and uploads. Not sure if these even exist.
User education :)
If it matters, the files will be mostly Word and Powerpoint documents.
Actually, despite the fact that you have more flexibility with AJAX in developing application, the problem of uploading multiple files is not solved yet.
To the thoughts you've mentioned in your question:
Google Docs:
Online apps like Google docs are certainly appealing for certain use cases. However, if you'd like to upload Word and Powerpoint slides, you don't want the content to be changed once you've uploaded the document. The problem is that Google Docs uses its own data format and therefore changes some of the formats. If you go for an online app, I'd go for a Document Management Solution. I'm sure there are plenty (even free ones) out there; however, I didn't use any on them yet.
WebDAV It is possible and seems to me like the best solution. You can embed WebDav like any directory. Documents are locked until a user releases the document. Unfortunately, you don't have a web front end to manage the files or administer access restrictions.
It
Flash or Java app They do exist, for sure. I'd prefer Flash over Java since Flash Apps still run smoother within a browser. I would definitely not use a rich application, even if it is a Java Web Start app that can be downloaded and opens in a separate window. More and more, users seem to accept browser based web applications. Which brings me to point 4:
User education You can educate them, sure. But in the end you want them to want to use the system. Most often, users get easily used to a tool. However, if they don't like the tool, they're not going to use it.
Clear instructions to save to their desktop is a start. Then clear instructions to go to the desktop to re-up it. I've not run across an online MSWord viewer/editor or whatever format the file is, but I'm sure they exist, now that Google Docs and a few other online versions of MSOffice exist.
I would make sure that there are easy to follow instructions, plus a tutorial somewhere else (perhaps with a video too) to guide users through the process.