Writing data into CSV file in C#

I am trying to write into a csv file row by row using C# language. Here is my function string first = reader[0].ToString(); string second=image.ToString(); string csv = string.Format(“{0},{1}\n”, first, second); File.WriteAllText(filePath, csv); The whole function runs inside a loop, and every row should be written to the csv file. In my case, next row … Read more

Properly escape a double quote in CSV

I have a line like this in my CSV: “Samsung U600 24″”,”10000003409″,”1″,”10000003427″ Quote next to 24 is used to express inches, while the quote just next to that quote closes the field. I’m reading the line with fgetcsv but the parser makes a mistake and reads the value as: Samsung U600 24″,10000003409″ I tried putting … Read more

Using stats_get_csv to return a list of popular posts by views with thumbnails

I recently learned that if you have WordPress.com Stats installed, you can take advantage of stats_get_csv() (Part of the WordPress.com Stats Plugin). <?php if ( function_exists(‘stats_get_csv’) && $top_posts = stats_get_csv(‘postviews’, ‘days=-1&limit=4′) ) : ?> <ol> <?php foreach ( $top_posts as $p ) : ?> <li><a href=”https://wordpress.stackexchange.com/questions/12189/<?php echo $p[“post_permalink’]; ?>”><?php echo $p[‘post_title’]; ?></a></li> <?php endforeach; ?> … Read more