Qur'an | Word by Word | Audio | Prayer Times | Android | New : beta.quran.com
__ Sign In
 
__

Java API - CSV Export Example

__

The program below demonstrates how to export an analysis table to a CSV file. The program lists all chapter names in the Quran using Buckwalter transliteration, then saves these results to a file.

Java Example

public class CsvExportExample {

    public static void main() {

        // Create a new analysis table.
        AnalysisTable table = new AnalysisTable(
            "ChapterNumber", "ChapterName");

        // Add chapter names using Buckwalter transliteration.
        for (Chapter chapter : Document.getChapters()) {
            table.add(
                chapter.getChapterNumber(),
                chapter.getName().toBuckwalter());
        }

        // Write results to screen.
        System.out.println(table);

        // Export results to a CSV file.
        table.writeFile("c:\\temp\\chapters.csv", ',');
    }
}

Program Output

ChapterNumber ChapterName
------------- -----------
1             AlfAtHp
2             Albqrp
3             A^l EmrAn
4             AlnsA'
5             AlmA}dp
6             Al>nEAm
7             Al>ErAf
8             Al>nfAl
9             Altwbp
10            ywns
11            hwd
12            ywsf
13            AlrEd
14            AbrAhym
15            AlHjr
16            AlnHl
17            Al<srA'
18            Alkhf
19            mrym
20            Th
21            Al>nbyA'
22            AlHj
23            Alm&mnwn
24            Alnwr
25            AlfrqAn
26            Al$ErA'
27            Alnml
28            AlqSS
29            AlEnkbwt
30            Alrwm
31            lqmAn
32            Alsjdp
33            Al>HzAb
34            sb<
35            fATr
36            ys
37            AlSAfAt
38            S
39            Alzmr
40            gAfr
41            fSlt
42            Al$wrY
43            Alzxrf
44            AldxAn
45            AljAvyp
46            Al>HqAf
47            mHmd
48            AlftH
49            AlHjrAt
50            q
51            Al*AryAt
52            AlTwr
53            Alnjm
54            Alqmr
55            AlrHmn
56            AlwAqEp
57            AlHdyd
58            AlmjAdlp
59            AlH$r
60            AlmmtHnp
61            AlSf
62            AljmEp
63            AlmnAfqwn
64            AltgAbn
65            AlTlAq
66            AltHrym
67            Almlk
68            Alqlm
69            AlHAqp
70            AlmEArj
71            nwH
72            Aljn
73            Almzml
74            Almdvr
75            AlqyAmp
76            AlAnsAn
77            AlmrslAt
78            Alnb<
79            AlnAzEAt
80            Ebs
81            Altkwyr
82            Al<nfTAr
83            AlmTffyn
84            Al<n$qAq
85            Albrwj
86            AlTArq
87            Al>ElY
88            AlgA$yp
89            Alfjr
90            Albld
91            Al$ms
92            Allyl
93            AlDHY
94            Al$rH
95            Altyn
96            AlElq
97            Alqdr
98            Albynp
99            Alzlzlp
100           AlEAdyAt
101           AlqArEp
102           AltkAvr
103           AlESr
104           Alhmzp
105           Alfyl
106           qry$
107           AlmAEwn
108           Alkwvr
109           AlkAfrwn
110           AlnSr
111           Almsd
112           Al<xlAS
113           Alflq
114           AlnAs

Discussion

The writeFile() method is used to export an analysis table to a file. The default is a tab delimited file, but the delimiter is configurable. The above example exports a CSV file by specifying a comma as the delimiter character.

See Also

Language Research Group
University of Leeds
__